version 1.49, 2005/04/06 21:21:36
|
version 1.50, 2005/05/13 20:53:39
|
|
|
return(operator==((const void *)b._routine)); | return(operator==((const void *)b._routine)); |
} | } |
private: | private: |
void execute(void) { _routine(_arg); } |
void execute() { _routine(_arg); } |
cleanup_handler(); | cleanup_handler(); |
void (*_routine)(void *); | void (*_routine)(void *); |
| |
|
|
* You, the developer has to make sure that there are | * You, the developer has to make sure that there are |
* no situations in which this can arise (ie, have a | * no situations in which this can arise (ie, have a |
* lock for the function which manipulates the TSD. | * lock for the function which manipulates the TSD. |
|
* |
|
* @exception NullPointer |
*/ | */ |
void put_data(void (*del)(void *), size_t size, void *data ) throw(NullPointer) |
void put_data(void (*del)(void *), size_t size, void *data ) |
{ | { |
if(_data != NULL) | if(_data != NULL) |
if(_delete_func != NULL) | if(_delete_func != NULL) |
|
|
return ; | return ; |
} | } |
| |
size_t get_size(void) { return _size; } |
size_t get_size() { return _size; } |
| |
/** | /** |
* This function is used to retrieve data from the | * This function is used to retrieve data from the |
|
|
| |
} | } |
| |
void copy_data(void **buf, size_t *size) throw(NullPointer) |
// @exception NullPointer |
|
void copy_data(void **buf, size_t *size) |
{ | { |
if((buf == NULL) || (size == NULL)) | if((buf == NULL) || (size == NULL)) |
throw NullPointer() ; | throw NullPointer() ; |
|
|
available. ATTN: The result is undefined for any other | available. ATTN: The result is undefined for any other |
type of failure. (See Bugzilla 972) | type of failure. (See Bugzilla 972) |
*/ | */ |
Boolean run(void); |
Boolean run(); |
| |
// get the user parameter | // get the user parameter |
inline void *get_parm(void) { return _thread_parm; } |
inline void *get_parm() { return _thread_parm; } |
| |
// cancellation must be deferred (not asynchronous) | // cancellation must be deferred (not asynchronous) |
// for user-level threads the thread itself can decide | // for user-level threads the thread itself can decide |
// when it should die. | // when it should die. |
void cancel(void); |
void cancel(); |
| |
// cancel if there is a pending cancellation request | // cancel if there is a pending cancellation request |
void test_cancel(void); |
void test_cancel(); |
| |
Boolean is_cancelled(void); |
Boolean is_cancelled(); |
| |
// for user-level threads - put the calling thread | // for user-level threads - put the calling thread |
// to sleep and jump to the thread scheduler. | // to sleep and jump to the thread scheduler. |
|
|
// or gnu portable threads will have an existing | // or gnu portable threads will have an existing |
// routine that can be mapped to this method | // routine that can be mapped to this method |
| |
void thread_switch(void); |
void thread_switch(); |
| |
#if defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) | #if defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) |
// suspend this thread | // suspend this thread |
void suspend(void) ; |
void suspend(); |
| |
// resume this thread | // resume this thread |
void resume(void) ; |
void resume(); |
#endif | #endif |
| |
static void sleep(Uint32 msec) ; | static void sleep(Uint32 msec) ; |
| |
// block the calling thread until this thread terminates | // block the calling thread until this thread terminates |
void join( void ); |
void join(); |
void thread_init(void); |
void thread_init(); |
| |
// thread routine needs to call this function when | // thread routine needs to call this function when |
// it is ready to exit | // it is ready to exit |
|
|
| |
// stack of functions to be called when thread terminates | // stack of functions to be called when thread terminates |
// will be called last in first out (LIFO) | // will be called last in first out (LIFO) |
void cleanup_push( void (*routine) (void *), void *parm ) throw(IPCException); |
// @exception IPCException |
void cleanup_pop(Boolean execute = true) throw(IPCException); |
void cleanup_push(void (*routine) (void *), void *parm); |
|
|
|
// @exception IPCException |
|
void cleanup_pop(Boolean execute = true); |
| |
// create and initialize a tsd | // create and initialize a tsd |
inline void create_tsd(const char *key, int size, void *buffer) throw(IPCException) |
// @exception IPCException |
|
inline void create_tsd(const char *key, int size, void *buffer) |
{ | { |
AutoPtr<thread_data> tsd(new thread_data(key, size, buffer)); | AutoPtr<thread_data> tsd(new thread_data(key, size, buffer)); |
_tsd.insert_first(tsd.get()); | _tsd.insert_first(tsd.get()); |
|
|
| |
// get the buffer associated with the key | // get the buffer associated with the key |
// NOTE: this call leaves the tsd LOCKED !!!! | // NOTE: this call leaves the tsd LOCKED !!!! |
inline void *reference_tsd(const char *key) throw(IPCException) |
// @exception IPCException |
|
inline void *reference_tsd(const char *key) |
{ | { |
_tsd.lock(); | _tsd.lock(); |
thread_data *tsd = _tsd.reference(key); | thread_data *tsd = _tsd.reference(key); |
|
|
return(NULL); | return(NULL); |
} | } |
| |
inline void *try_reference_tsd(const char *key) throw(IPCException) |
// @exception IPCException |
|
inline void *try_reference_tsd(const char *key) |
{ | { |
_tsd.try_lock(); | _tsd.try_lock(); |
thread_data *tsd = _tsd.reference(key); | thread_data *tsd = _tsd.reference(key); |
|
|
| |
// release the lock held on the tsd | // release the lock held on the tsd |
// NOTE: assumes a corresponding and prior call to reference_tsd() !!! | // NOTE: assumes a corresponding and prior call to reference_tsd() !!! |
inline void dereference_tsd(void) throw(IPCException) |
// @exception IPCException |
|
inline void dereference_tsd() |
{ | { |
_tsd.unlock(); | _tsd.unlock(); |
} | } |
| |
// delete the tsd associated with the key | // delete the tsd associated with the key |
inline void delete_tsd(const char *key) throw(IPCException) |
// @exception IPCException |
|
inline void delete_tsd(const char *key) |
{ | { |
AutoPtr<thread_data> tsd(_tsd.remove(key)); | AutoPtr<thread_data> tsd(_tsd.remove(key)); |
} | } |
| |
// Note: Caller must delete the thread_data object returned (if not null) | // Note: Caller must delete the thread_data object returned (if not null) |
inline void *remove_tsd(const char *key) throw(IPCException) |
// @exception IPCException |
|
inline void *remove_tsd(const char *key) |
{ | { |
return(_tsd.remove((const void *)key)); | return(_tsd.remove((const void *)key)); |
} | } |
| |
inline void empty_tsd(void) throw(IPCException) |
// @exception IPCException |
|
inline void empty_tsd() |
{ | { |
try | try |
{ | { |
|
|
| |
// create or re-initialize tsd associated with the key | // create or re-initialize tsd associated with the key |
// if the tsd already exists, delete the existing buffer | // if the tsd already exists, delete the existing buffer |
|
// @exception IPCException |
void put_tsd(const char *key, void (*delete_func)(void *), Uint32 size, void *value) | void put_tsd(const char *key, void (*delete_func)(void *), Uint32 size, void *value) |
throw(IPCException) |
|
|
|
{ | { |
PEGASUS_ASSERT(key != NULL); | PEGASUS_ASSERT(key != NULL); |
AutoPtr<thread_data> tsd ; | AutoPtr<thread_data> tsd ; |
|
|
catch(IPCException& e) { e = e; throw; } | catch(IPCException& e) { e = e; throw; } |
ntsd.release(); | ntsd.release(); |
} | } |
inline PEGASUS_THREAD_RETURN get_exit(void) { return _exit_code; } |
inline PEGASUS_THREAD_RETURN get_exit() { return _exit_code; } |
inline PEGASUS_THREAD_TYPE self(void) {return pegasus_thread_self(); } |
inline PEGASUS_THREAD_TYPE self() {return pegasus_thread_self(); } |
| |
PEGASUS_THREAD_HANDLE getThreadHandle() {return _handle;} | PEGASUS_THREAD_HANDLE getThreadHandle() {return _handle;} |
| |
|
|
return(operator==((const void *)&b )); | return(operator==((const void *)&b )); |
} | } |
| |
void detach(void); |
void detach(); |
| |
// | // |
// Gets the Thread object associated with the caller's thread. | // Gets the Thread object associated with the caller's thread. |
|
|
| |
static Sint8 initializeKey(); // l10n | static Sint8 initializeKey(); // l10n |
| |
inline void create_tsd(const char *key ) throw(IPCException) |
// @exception IPCException |
|
inline void create_tsd(const char *key ) |
{ | { |
AutoPtr<thread_data> tsd(new thread_data(key)); | AutoPtr<thread_data> tsd(new thread_data(key)); |
_tsd.insert_first(tsd.get()); | _tsd.insert_first(tsd.get()); |