#include <ace/Thread_Manager.h > class ACE_Thread_Manager {
public:
enum{ DEFAULT_SIZE = 100 };
inline ACE_Thread_Manager (int = 0);
inline ~ACE_Thread_Manager (void);
inline int open (size_t = DEFAULT_SIZE);
inline int close (void);
inline int spawn ( ACE_THR_FUNC, void * = 0, long = 0, ACE_thread_t * = 0, ACE_hthread_t * = 0, u_int = 0, int = -1, void * = 0, size_t = 0 );
friend class ACE_Thread_Control;
enum{ DEFAULT_SIZE = 100 };
ACE_Thread_Manager ( size_t size = ACE_Thread_Manager::DEFAULT_SIZE );
~ACE_Thread_Manager (void);
int open (size_t size = DEFAULT_SIZE);
int close (void);
int spawn ( ACE_THR_FUNC func, void *args = 0, long flags = THR_NEW_LWP, ACE_thread_t * = 0, ACE_hthread_t *t_handle = 0, u_int priority = 0, int grp_id = -1, void *stack = 0, size_t stack_size = 0 );
int spawn_n ( int n, ACE_THR_FUNC func, void *args = 0, long flags = THR_NEW_LWP, u_int priority = 0, int grp_id = -1 );
void *exit (void *status, int do_thread_exit = 1);
int wait (const ACE_Time_Value *timeout = 0);
int thread_descriptor (ACE_thread_t, ACE_Thread_Descriptor &);
int hthread_descriptor (ACE_hthread_t, ACE_Thread_Descriptor &);
int thr_self (ACE_hthread_t &);
int suspend_all (void);
int suspend (ACE_thread_t);
int suspend_grp (int grp_id);
int testsuspend (ACE_thread_t t_id);
int resume_all (void);
int resume (ACE_thread_t);
int resume_grp (int grp_id);
int testresume (ACE_thread_t t_id);
int kill_all (int signum);
int kill (ACE_thread_t, int signum);
int kill_grp (int grp_id, int signum);
int cancel_all (void);
int cancel (ACE_thread_t);
int cancel_grp (int grp_id);
int testcancel (ACE_thread_t t_id);
int set_grp (ACE_thread_t, int grp_id);
int get_grp (ACE_thread_t, int &grp_id);
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
private:
int resize (size_t);
int spawn_i ( ACE_THR_FUNC func, void *args, long flags, ACE_thread_t * = 0, ACE_hthread_t *t_handle = 0, u_int priority = 0, int grp_id = -1, void *stack = 0, size_t stack_size = 0 );
int find (ACE_thread_t t_id);
int insert_thr ( ACE_thread_t t_id, ACE_hthread_t, int grp_id = -1 );
int append_thr ( ACE_thread_t t_id, ACE_hthread_t, ACE_Thread_State, int grp_id );
void remove_thr (int i);
int thread_descriptor_i (ACE_thread_t, ACE_Thread_Descriptor &);
int hthread_descriptor_i (ACE_hthread_t, ACE_Thread_Descriptor &);
typedef int (ACE_Thread_Manager::*THR_FUNC)(int, int);
int check_state (ACE_Thread_State state, ACE_thread_t thread);
int apply_grp (int grp_id, THR_FUNC, int = 0);
int apply_all (THR_FUNC, int = 0);
int resume_thr (int i);
int suspend_thr (int i);
int kill_thr (int i, int signum);
int cancel_thr (int i);
ACE_Thread_Descriptor *thr_table_;
size_t max_table_size_;
size_t current_count_;
int grp_id_;
ACE_Thread_Mutex lock_;
ACE_Condition_Thread_Mutex zero_cond_;
};
ACE_Thread_Manager (size_t size = ACE_Thread_Manager::DEFAULT_SIZE);
~ACE_Thread_Manager (void);
int open (size_t size = DEFAULT_SIZE);
int close (void);
int spawn (
ACE_THR_FUNC func,
void *args = 0,
long flags = THR_NEW_LWP,
ACE_thread_t * = 0,
ACE_hthread_t *t_handle = 0,
u_int priority = 0,
int grp_id = -1,
void *stack = 0,
size_t stack_size = 0
);
func
.
int spawn_n (
int n,
ACE_THR_FUNC func,
void *args = 0,
long flags = THR_NEW_LWP,
u_int priority = 0,
int grp_id = -1
);
func
.
void *exit (void *status, int do_thread_exit = 1);
do_thread_exit
is
non-0 then ACE_Thread::exit
is called to exit the thread, in
which case status
is passed as the exit value of the thread.
int wait (const ACE_Time_Value *timeout = 0);
timeout
expires. Returns 0 on success and -1 on failure.
ACE_Thread_Descriptors
.
int thread_descriptor (ACE_thread_t, ACE_Thread_Descriptor &);
int hthread_descriptor (ACE_hthread_t, ACE_Thread_Descriptor &);
int thr_self (ACE_hthread_t &);
int suspend_all (void);
int suspend (ACE_thread_t);
int suspend_grp (int grp_id);
int testsuspend (ACE_thread_t t_id);
t_id
is inactive (i.e., suspended), else false.
int resume_all (void);
int resume (ACE_thread_t);
int resume_grp (int grp_id);
int testresume (ACE_thread_t t_id);
t_id
is active (i.e., resumed), else false.
int kill_all (int signum);
int kill (ACE_thread_t, int signum);
int kill_grp (int grp_id, int signum);
int cancel_all (void);
int cancel (ACE_thread_t);
int cancel_grp (int grp_id);
int testcancel (ACE_thread_t t_id);
t_id
is cancelled, else false.
int set_grp (ACE_thread_t, int grp_id);
int get_grp (ACE_thread_t, int &grp_id);
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
typedef int (ACE_Thread_Manager::*THR_FUNC)(int, int);
int check_state (ACE_Thread_State state, ACE_thread_t thread);
thread
is in a particular state
.
This call updates the TSS cache if possible to speed up
subsequent searches.
int apply_grp (int grp_id, THR_FUNC, int = 0);
func
to all members of the table that match the grp_id
.
int apply_all (THR_FUNC, int = 0);
func
to all members of the table.
int resume_thr (int i);
i
.
int suspend_thr (int i);
i
.
int kill_thr (int i, int signum);
signum
to the thread at index i
.
int cancel_thr (int i);
i
.
ACE_Thread_Descriptor *thr_table_;
size_t max_table_size_;
size_t current_count_;
int grp_id_;
ACE_Thread_Mutex lock_;
ACE_Condition_Thread_Mutex zero_cond_;