Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# ACE_Thread Class Reference

Provides a wrapper for threads. More...

`#include <Thread.h>`

List of all members.

## Static Public Methods
int | spawn (ACE_THR_FUNC func, void *arg=0, long flags=THR_NEW_LWP|THR_JOINABLE, ACE_thread_t *t_id=0, ACE_hthread_t *t_handle=0, long priority=ACE_DEFAULT_THREAD_PRIORITY, void *stack=0, size_t stack_size=0, ACE_Thread_Adapter *thread_adapter=0)
size_t | spawn_n (size_t n, ACE_THR_FUNC func, void *arg=0, long flags=THR_NEW_LWP|THR_JOINABLE, long priority=ACE_DEFAULT_THREAD_PRIORITY, void *stack[]=0, size_t stack_size[]=0, ACE_Thread_Adapter *thread_adapter=0)
size_t | spawn_n (ACE_thread_t thread_ids[], size_t n, ACE_THR_FUNC func, void *arg, long flags, long priority=ACE_DEFAULT_THREAD_PRIORITY, void *stack[]=0, size_t stack_size[]=0, ACE_hthread_t thread_handles[]=0, ACE_Thread_Adapter *thread_adapter=0)
int | join (ACE_thread_t, ACE_thread_t *, ACE_THR_FUNC_RETURN *status)
| Wait for one or more threads to exit and reap their exit status.
int | join (ACE_hthread_t, ACE_THR_FUNC_RETURN *=0)
| Wait for one thread to exit and reap its exit status.
int | resume (ACE_hthread_t)
| Continue the execution of a previously suspended thread.
int | suspend (ACE_hthread_t)
| Suspend the execution of a particular thread.
int | getprio (ACE_hthread_t id, int &priority)
| Get the priority of a particular thread.
int | getprio (ACE_hthread_t id, int &priority, int &policy)
| Get the priority and policy of a particular thread.
int | setprio (ACE_hthread_t id, int priority, int policy=-1)
| Set the priority of a particular thread.
int | kill (ACE_thread_t, int signum)
| Send a signal to the thread.
void | yield (void)
| Yield the thread to another.
void | self (ACE_hthread_t &t_handle)
ACE_thread_t | self (void)
| Return the unique ID of the thread.
void | exit (ACE_THR_FUNC_RETURN status=0)
int | getconcurrency (void)
| Get the LWP concurrency level of the process.
int | setconcurrency (int new_level)
| Set the LWP concurrency level of the process.
int | sigsetmask (int how, const sigset_t *sigset, sigset_t *osigset=0)
| Change and/or examine calling thread's signal mask.
int | keycreate (ACE_thread_key_t *keyp, ACE_THR_DEST destructor, void *=0)
int | keyfree (ACE_thread_key_t key)
| Free up the key so that other threads can reuse it.
int | setspecific (ACE_thread_key_t key, void *value)
int | getspecific (ACE_thread_key_t key, void **valuep)
int | disablecancel (struct cancel_state *old_state)
| Disable thread cancellation.
int | enablecancel (struct cancel_state *old_state, int flag)
| Enable thread cancellation.
int | setcancelstate (struct cancel_state &new_state, struct cancel_state *old_state)
| Set the cancellation state.
int | cancel (ACE_thread_t t_id)
void | testcancel (void)
| Test the cancel.
## Private Methods
| ACE_Thread (void)
| Ensure that we don't get instantiated.

## Detailed Description

Provides a wrapper for threads.

This class provides a common interface that is mapped onto POSIX Pthreads, Solaris threads, Win32 threads, VxWorks threads, or pSoS threads. Note, however, that it is generally a better idea to use the <ACE_Thread_Manager> programming API rather than the <ACE_Thread> API since the thread manager is more powerful.

## Constructor & Destructor Documentation

ACE_Thread::ACE_Thread | ( | void |  | ) | `[private]`

| Ensure that we don't get instantiated.

## Member Function Documentation

ACE_INLINE int ACE_Thread::cancel | ( | ACE_thread_t | t_id | ) | `[static]`

| Cancel a thread. Note that this method is only portable on platforms, such as POSIX pthreads, that support thread cancellation.

ACE_INLINE int ACE_Thread::disablecancel | ( | struct cancel_state * | old_state | ) | `[static]`

| Disable thread cancellation.

ACE_INLINE int ACE_Thread::enablecancel | ( | struct cancel_state * | old_state,
|  | int | flag
| ) | `[static]`

| Enable thread cancellation.

ACE_INLINE void ACE_Thread::exit | ( | ACE_THR_FUNC_RETURN | status = 0 | ) | `[static]`

| Exit the current thread and return "status". Should _not_ be called by main thread.

ACE_INLINE int ACE_Thread::getconcurrency | ( | void |  | ) | `[static]`

| Get the LWP concurrency level of the process.

ACE_INLINE int ACE_Thread::getprio | ( | ACE_hthread_t | id,
|  | int & | priority,
|  | int & | policy
| ) | `[static]`

| Get the priority and policy of a particular thread.

ACE_INLINE int ACE_Thread::getprio | ( | ACE_hthread_t | id,
|  | int & | priority
| ) | `[static]`

| Get the priority of a particular thread.

ACE_INLINE int ACE_Thread::getspecific | ( | ACE_thread_key_t | key,
|  | void ** | valuep
| ) | `[static]`

| Stores the current value bound to <key> for the calling thread into the location pointed to by <valuep>.

ACE_INLINE int ACE_Thread::join | ( | ACE_hthread_t | ,
|  | ACE_THR_FUNC_RETURN * | = 0
| ) | `[static]`

| Wait for one thread to exit and reap its exit status.

ACE_INLINE int ACE_Thread::join | ( | ACE_thread_t | ,
|  | ACE_thread_t * | ,
|  | ACE_THR_FUNC_RETURN * | status
| ) | `[static]`

| Wait for one or more threads to exit and reap their exit status.

ACE_INLINE int ACE_Thread::keycreate | ( | ACE_thread_key_t * | keyp,
|  | ACE_THR_DEST | destructor,
|  | void * | = 0
| ) | `[static]`

| Allocates a <keyp> that is used to identify data that is specific to each thread in the process. The key is global to all threads in the process.

ACE_INLINE int ACE_Thread::keyfree | ( | ACE_thread_key_t | key | ) | `[static]`

| Free up the key so that other threads can reuse it.

ACE_INLINE int ACE_Thread::kill | ( | ACE_thread_t | ,
|  | int | signum
| ) | `[static]`

| Send a signal to the thread.

ACE_INLINE int ACE_Thread::resume | ( | ACE_hthread_t |  | ) | `[static]`

| Continue the execution of a previously suspended thread.

ACE_INLINE ACE_thread_t ACE_Thread::self | ( | void |  | ) | `[static]`

| Return the unique ID of the thread.

ACE_INLINE void ACE_Thread::self | ( | ACE_hthread_t & | t_handle | ) | `[static]`

| Return the unique kernel handle of the thread. Note that on Win32 this is actually a pseudohandle, which cannot be shared with other processes or waited on by threads. To locate the real handle, please use the ACE_Thread_Manager::thr_self() method.

ACE_INLINE int ACE_Thread::setcancelstate | ( | struct cancel_state & | new_state,
|  | struct cancel_state * | old_state
| ) | `[static]`

| Set the cancellation state.

ACE_INLINE int ACE_Thread::setconcurrency | ( | int | new_level | ) | `[static]`

| Set the LWP concurrency level of the process.

ACE_INLINE int ACE_Thread::setprio | ( | ACE_hthread_t | id,
|  | int | priority,
|  | int | policy = -1
| ) | `[static]`

| Set the priority of a particular thread.

ACE_INLINE int ACE_Thread::setspecific | ( | ACE_thread_key_t | key,
|  | void * | value
| ) | `[static]`

| Bind value to the thread-specific data key, <key>, for the calling thread.

ACE_INLINE int ACE_Thread::sigsetmask | ( | int | how,
|  | const sigset_t * | sigset,
|  | sigset_t * | osigset = 0
| ) | `[static]`

| Change and/or examine calling thread's signal mask.

ACE_INLINE int ACE_Thread::spawn | ( | ACE_THR_FUNC | func,
|  | void * | arg = 0,
|  | long | flags = THR_NEW_LWP|THR_JOINABLE,
|  | ACE_thread_t * | t_id = 0,
|  | ACE_hthread_t * | t_handle = 0,
|  | long | priority = ACE_DEFAULT_THREAD_PRIORITY,
|  | void * | stack = 0,
|  | size_t | stack_size = 0,
|  | ACE_Thread_Adapter * | thread_adapter = 0
| ) | `[static]`

| Creates a new thread having <flags> attributes and running <func> with <args> (if <thread_adapter> is non-0 then <func> and <args> are ignored and are obtained from <thread_adapter>). <thr_id> and <t_handle> are set to the thread's ID and handle (?), respectively. The thread runs at <priority> priority (see below). The <flags> are a bitwise-OR of the following: = BEGIN<INDENT> THR_CANCEL_DISABLE, THR_CANCEL_ENABLE, THR_CANCEL_DEFERRED, THR_CANCEL_ASYNCHRONOUS, THR_BOUND, THR_NEW_LWP, THR_DETACHED, THR_SUSPENDED, THR_DAEMON, THR_JOINABLE, THR_SCHED_FIFO, THR_SCHED_RR, THR_SCHED_DEFAULT, THR_EXPLICIT_SCHED, THR_SCOPE_SYSTEM, THR_SCOPE_PROCESS = END<INDENT> By default, or if <priority> is set to ACE_DEFAULT_THREAD_PRIORITY, an "appropriate" priority value for the given scheduling policy (specified in <flags}>, e.g., <THR_SCHED_DEFAULT>) is used. This value is calculated dynamically, and is the median value between the minimum and maximum priority values for the given policy. If an explicit value is given, it is used. Note that actual priority values are EXTREMEMLY implementation-dependent, and are probably best avoided. Note that <thread_adapter> is always deleted when <spawn> is called, so it must be allocated with global operator new.

size_t ACE_Thread::spawn_n | ( | ACE_thread_t | thread_ids[],
|  | size_t | n,
|  | ACE_THR_FUNC | func,
|  | void * | arg,
|  | long | flags,
|  | long | priority = ACE_DEFAULT_THREAD_PRIORITY,
|  | void * | stack[] = 0,
|  | size_t | stack_size[] = 0,
|  | ACE_hthread_t | thread_handles[] = 0,
|  | ACE_Thread_Adapter * | thread_adapter = 0
| ) | `[static]`

| Spawn <n> new threads, which execute <func> with argument <arg> (if <thread_adapter> is non-0 then <func> and <args> are ignored and are obtained from <thread_adapter>). The thread_ids of successfully spawned threads will be placed into the <thread_ids> buffer (which must be the same size as <n>). If <stack> != 0 it is assumed to be an array of <n> pointers to the base of the stacks to use for the threads being spawned. If <stack_size> != 0 it is assumed to be an array of <n> values indicating how big each of the corresponding <stack>s are. If <thread_handles> != 0 it is assumed to be an array of <n> thread_handles that will be assigned the values of the thread handles being spawned. Returns the number of threads actually spawned (if this doesn't equal the number requested then something has gone wrong and <errno> will explain...). See also: spawn()

size_t ACE_Thread::spawn_n | ( | size_t | n,
|  | ACE_THR_FUNC | func,
|  | void * | arg = 0,
|  | long | flags = THR_NEW_LWP|THR_JOINABLE,
|  | long | priority = ACE_DEFAULT_THREAD_PRIORITY,
|  | void * | stack[] = 0,
|  | size_t | stack_size[] = 0,
|  | ACE_Thread_Adapter * | thread_adapter = 0
| ) | `[static]`

| Spawn N new threads, which execute <func> with argument <arg> (if <thread_adapter> is non-0 then <func> and <args> are ignored and are obtained from <thread_adapter>). If <stack> != 0 it is assumed to be an array of <n> pointers to the base of the stacks to use for the threads being spawned. Likewise, if <stack_size> != 0 it is assumed to be an array of <n> values indicating how big each of the corresponding <stack>s are. Returns the number of threads actually spawned (if this doesn't equal the number requested then something has gone wrong and <errno> will explain...). See also: spawn()

ACE_INLINE int ACE_Thread::suspend | ( | ACE_hthread_t |  | ) | `[static]`

| Suspend the execution of a particular thread.

ACE_INLINE void ACE_Thread::testcancel | ( | void |  | ) | `[static]`

| Test the cancel.

ACE_INLINE void ACE_Thread::yield | ( | void |  | ) | `[static]`

| Yield the thread to another.

The documentation for this class was generated from the following files:

- /export2/deucetmp/bala/release_try/ACE_wrappers/ace/Thread.h
- /export2/deucetmp/bala/release_try/ACE_wrappers/ace/Thread.cpp
- /export2/deucetmp/bala/release_try/ACE_wrappers/ace/Thread.i