The Instances property imposes constraints on the concurrent execution of the component in different threads. You can view and change these properties using the Instances tab of the component’s property sheet.
For a single-threaded component, multiple instances may exist simultaneously, but only one can be active at any one time. EAServer synchronizes instantiations, method invocations, and destructions of all instances. Use the single-threaded model if your component shares volatile global data or stateful resources between instances. For example, volatile global data might be a counter that is stored in a global variable. Sharing a stateful resource would occur if, for example, every component instance opened the same file and wrote text to it. Either example requires the single-threading model. To enable single-threading, do not select any of the options in the Instance Properties tab.
The following settings specify the constraints that are placed on concurrent execution of different instances of the component. The choices are:
Concurrency – multiple invocations can be processed concurrently; that is, multiple instances can be simultaneously active on different threads. The component must be thread-safe. Use this setting if the component code uses no volatile global data and does not share stateful resources (such as a file) among instances. This threading model offers the highest performance.
The EAServer shared properties feature provides a means to share data safely among instances of a multiple-threaded component. See “Share data between C or C++ components” for more information.
Bind Thread – instances are bound to the creating thread. The component uses thread-local storage. The Bind Thread check box determines whether a component instance is always invoked in the same thread or can be invoked on any thread. If Bind Thread is not selected, then EAServer can invoke the component’s methods with any thread.
Do not select this check box, unless your component uses thread-local storage. EAServer provides no APIs for thread-local storage, but you can issue thread system calls from the C component code. Do not use thread-local storage if you are implementing new components. Instead, use the JagGetInstanceData and JagSetInstanceData routines to associate data with a specific component. If you incorporate existing code that uses thread-local storage into a C component, select this check box.
Pooling – instances are pooled after a commit or rollback.
Sharing – a single shared instance services all client requests. Only one instance of the component can exist at any one time. Attempts to create new instances when one already exists will fail. In this model, only one instance of the component may exist at any one time. Attempts to create new instances when one already exists will fail. This option offers the worst performance. Select this check box only if the logic in your code requires that only one component instance exist at one time.
Copyright © 2005. Sybase Inc. All rights reserved. |