IlsThreadContext
 
IlsThreadContext
Category 
Thread utility class template - API FOR ADVANCED USERS
Inheritance Path 
IlsThreadContext
Description 
This class template allows an application to attach one instance of a class to any thread.
Libraries 
<server> and <mvcomp>
Header File 
#include <ilserver/ilthread.h>
Synopsis 
template<class DataType>
class IlsThreadContext
{
public:
 
static IlsBoolean Set(DataType*, IlsContextTerminatedFunc =0);
static DataType* Get(IlsBoolean = IlsFalse);
 
IlsBoolean setContext(DataType*, IlsContextTerminatedFunc = 0);
DataType* getContext(IlsBoolean = IlsFalse);
};
Member Functions 
[static] IlsBoolean Set(DataType*, ILS_CUT_DIRECTIVE = 0);
This static member function associates a context with a thread. Thread contexts
can only be associated with the current thread. When you associate a context with a thread, you can add a callback which will be called when the thread exits, either by terminating its start function, or by being exited via the static member function IlsThread::ExitCurrentThread. It is the responsibility of the application to delete the context if necessary, either by an explicit delete at the end of the thread start function, or by using the context callback function which passes a pointer to the context when the thread exits. If this member function returns IlsFalse, then the context already exists. In this case, the new context is not associated with the thread.
[static] DataType* Get(IlsBoolean = IlsFalse);
This static member function retrieves a context associated with a thread. Thread contexts can be retrieved only from the current thread. The optional parameter to this function can be set to IlsTrue to permanently remove the context from the thread. As for the set member function, it is the responsibility of the application to delete the context returned by this function, if appropriate.
IlsBoolean setContext(DataType*, IlsContextTerminatedFunc = 0);
This member function behaves like the function Set. The difference is that setContext can be called on an instance of the class IlsThreadContext, so that you can have more than one context per thread. When you call this function, the contexts are stored locally in the instance of IlsThreadContext.
DataType* getContext(IlsBoolean = IlsFalse);
This member function behaves like the function Get. The difference is that getContext can be called on an instance of the class IlsThreadContext, so that you can have more than one context per thread. When you call this function, the contexts are stored locally in the instance of IlsThreadContext.
See Also 
ILS_CUT_DIRECTIVE, IlsThread

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.