NAME
ACE_Thread_Adapter - Converts a C++ function into a function ace_thread_adapter function that can be called from a thread creation routine (e.g., pthread_create or _beginthreadex) that expects an extern "C" entry point. This class also makes it possible to transparently provide hooks to register a thread with an ACE_Thread_Manager.
SYNOPSIS
#include <ace/OS.h>
class ACE_Thread_Adapter
{
public:
ACE_Thread_Adapter (
ACE_THR_FUNC user_func,
void *arg,
ACE_THR_C_FUNC entry_point = (ACE_THR_C_FUNC) ace_thread_adapter,
ACE_Thread_Manager *thr_mgr = 0,
ACE_Thread_Descriptor *td = 0 ,
ACE_SEH_EXCEPT_HANDLER selector = 0,
ACE_SEH_EXCEPT_HANDLER handler = 0
);
void *invoke (void);
ACE_Thread_Manager *thr_mgr (void);
ACE_THR_C_FUNC entry_point (void);
private:
~ACE_Thread_Adapter (void);
void inherit_log_msg (void);
ACE_THR_FUNC user_func_;
void *arg_;
ACE_THR_C_FUNC entry_point_;
ACE_Thread_Manager *thr_mgr_;
ACE_OS_Thread_Descriptor *thr_desc_;
ACE_OSTREAM_TYPE *ostream_;
u_long priority_mask_;
int tracing_enabled_;
int restart_;
int trace_depth_;
ACE_SEH_EXCEPT_HANDLER seh_except_selector_;
ACE_SEH_EXCEPT_HANDLER seh_except_handler_;
friend class ACE_Thread_Adapter_Has_Private_Destructor;
};
DESCRIPTION
This class is used in ACE_OS::thr_create. In general, the thread that creates an object of this class is different from the thread that calls invoke on this object. Therefore, the invoke method is responsible for deleting itself.
PUBLIC MEMBERS
ACE_Thread_Adapter (
ACE_THR_FUNC user_func,
void *arg,
ACE_THR_C_FUNC entry_point = (ACE_THR_C_FUNC) ace_thread_adapter,
ACE_Thread_Manager *thr_mgr = 0,
ACE_Thread_Descriptor *td = 0 ,
ACE_SEH_EXCEPT_HANDLER selector = 0,
ACE_SEH_EXCEPT_HANDLER handler = 0
);
Constructor.
void *invoke (void);
Execute the user_func_ with the arg. This function deletes this, thereby rendering the object useless after the call returns.
ACE_Thread_Manager *thr_mgr (void);
Accessor for the optional Thread_Manager.
ACE_THR_C_FUNC entry_point (void);
Accessor for the C entry point function to the OS thread creation routine.
PRIVATE MEMBERS
~ACE_Thread_Adapter (void);
Ensure that this object must be allocated on the heap.
void inherit_log_msg (void);
Inherit the logging features if the parent thread has an ACE_Log_Msg.
ACE_THR_FUNC user_func_;
Thread startup function passed in by the user (C++ linkage).
void *arg_;
Argument to thread startup function.
ACE_THR_C_FUNC entry_point_;
Entry point to the underlying OS thread creation call (C linkage).
ACE_Thread_Manager *thr_mgr_;
Optional thread manager.
ACE_OS_Thread_Descriptor *thr_desc_;
Optional thread descriptor. Passing this pointer in will force the spawned thread to cache this location in Log_Msg and wait until Thread_Manager fills in all information in thread descriptor.
ACE_OSTREAM_TYPE *ostream_;
Ostream where the new TSS Log_Msg will use.
u_long priority_mask_;
Priority_mask to be used in new TSS Log_Msg.
int tracing_enabled_;
Are we allowing tracing in this thread?
int restart_;
Indicates whether we should restart system calls that are interrupted.
int trace_depth_;
Depth of the nesting for printing traces.
ACE_SEH_EXCEPT_HANDLER seh_except_selector_;
ACE_SEH_EXCEPT_HANDLER seh_except_handler_;
friend class ACE_Thread_Adapter_Has_Private_Destructor;
Friend declaration to avoid compiler warning: only defines a private destructor and has no friends.
AUTHOR
Doug Schmidt [email protected], Jesper S. M|ller [email protected], and a cast of thousands...
The ACE_Sched_Priority type should be used for platform-
independent thread and process priorities, by convention. int should be used for OS-specific priorities.
typedef for the _stat data structure
Giving unique ACE scoped names for some important
RTSignal-Related constants. Becuase sometimes, different platforms use different names for these constants.
LIBRARY
ace