Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

COM+ / Object Pooling / DECLARE_NOT_AGGREGATABLE

Posted on 2000-03-30
3
Medium Priority
?
600 Views
Last Modified: 2013-11-25
With a VB component object pooling is not possible.  With a C++ component it is but can lead to very strange results and data corruption.  From the brief MS help: When pooling is enabled objects will be recycled and reused.  Object pooling can only be enabled for components that a written to meet the reusability requirements for poolable objects.  

Sounds good!  Questions:

1) Can someone explain from an implementation point of view in C++ what would be needed to support object pooling?

2) Why would you ever choose not to enable pooling?

3) Any comments on JIT activation?

Thanks!
0
Comment
Question by:eeuserex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
gelbert earned 300 total points
ID: 2670934
Requirements for Poolable Objects
[This is preliminary documentation and subject to change. This technology works only on computers running Windows 2000 Beta 3 or later.]

Poolable objects must meet certain requirements to enable a single object instance to be used by multiple clients.

Stateless
Poolable objects should hold no client-specific state from client to client, to maintain security, consistency, and isolation. You can manage any per-client state using IObjectControl, performing context-specific initialization with Activate and cleaning up any client state with Deactivate. For more detail, see Controlling Object Lifetime and State.

No thread affinity
Poolable objects cannot be bound to a particular thread, otherwise performance could potentially be disastrous. For this reason, poolable objects cannot be marked Apartment model, they must run in the Multi-Threaded Apartment or the Neutral Apartment. In addition, poolable objects should not use thread local storage (TLS), nor should they aggregate the Free-Threaded Marshaller (FTM). For more detail about threading in COM+, see Concurrency.

Note that currently, the Microsoft Visual Basic development environment can only create Apartment model components. For this reason, Visual Basic components cannot be pooled.

Aggregatable
Poolable objects must support aggregation– that is, they must support being created with a pUnkOuter. When COM+ activates a pooled object it will create an aggregate to manage the lifetime of the pooled object and to call methods on IObjectControl. For details on writing aggregatable objects, see Aggregation.

Transactional components
Poolable objects that participate in transactions must manually enlist managed resources. If your object holds a managed resource such as a database connection while it is pooled, there will be no way for the resource manager to automatically enlist in a transaction when the object is activated in given context. Therefore, the object itself must handle the logic of detecting the transaction, turning off the resource manager's auto-enlistment, and manually enlisting any resources that it holds. In addition, a transactional pooled object should reflect the current state of its resources in IObjectControl::CanBePooled. For more detail, see Pooling Transactional Objects.

Implement IObjectControl to manage the object lifetime
Poolable objects should implement IObjectControl, though it is not strictly necessary to do so. Transactional components that are pooled, however, must implement IObjectControl. They should monitor the state of the resources they hold and indicate when they can't be reused; when CanBePooled returns false it will doom a transaction. For more detail, see Controlling Object Lifetime and State.

Language restrictions
Currently, components developed using Microsoft Visual Basic cannot be pooled, as these components will be apartment-model threaded.

Legacy components
Components can be pooled even if they are not specifically written with this in mind, so long as they are non-transactional and conform to the appropriate requirements above. It is not necessary to implement IObjectControl; a component that does not do so simply won't participate in managing its lifetime. If CanBePooled is not implemented, the object will always be reused, up until the pool maximum size.

0
 

Author Comment

by:eeuserex
ID: 2671107
Thanks for the information.  If you can answer the specific questions I would be happy to accept your comment as an answer.  Also, where did you find that specific documentation?
0
 

Author Comment

by:eeuserex
ID: 2671124
Found it on MSDN.  Also some other goodies...

Thanks.  For anyone else:

http://msdn.microsoft.com/isapi/msdnlib2.idc?theURL=/library/psdk/cossdk/pgservices_objectpooling_6ep3.htm
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question