Home Help Center

Thread-local memory in Ice service?

stwhitstwhit Member Stuart WhiteOrganization: PersonalProject: CORBA replacement
I'm trying to write an Ice service that, at initialization time, allocates and initializes a block of memory for each service thread.

When a client request is received, the server thread should acquire a pointer to a memory block, use it while servicing the request, and release the pointer when finished servicing the request.

I intend to detect Ice.ThreadPool.Server.SizeMax at init time, and use this value to allocate the thread memory blocks (so I know I'll never experience starvation attempting to acquire one of these memory blocks.
Ice::PropertiesPtr props = ic->getProperties();
Ice::Int maxThreads = props->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.SizeMax", 1);

So, my question is this: Does Ice contain any utility classes to facilitate this type of service?

Of course, I can write a class that maintains a list of pointers, uses mutexes to lock around the acquiring and releasing of the pointers, etc... But, before I did this, I wanted to make sure Ice didn't already have something for this purpose.

Or, perhaps, is there a better way to achieve thread-specific memory blocks for server threads?

Thanks!

Comments

  • dwaynedwayne St. John's, NewfoundlandMember Dwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications Engine
    Ice doe not have a built in feature to do exactly what you want but it does provide the ability to configure callbacks that are called whenever a Ice thread is created/destroyed. See 29.9.6 of the manual for details. One possibility is to make use of these hooks in order to set up thread-local storage in order to do what you want.

    Dwayne
Sign In or Register to comment.