version 1.1.2.13, 2001/10/03 16:55:03
|
version 1.1.2.15, 2001/10/25 15:41:01
|
|
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
class PEGASUS_EXPORT cleanup_handler |
class PEGASUS_COMMON_LINKAGE cleanup_handler |
{ | { |
| |
public: | public: |
|
|
| |
/////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// |
| |
class PEGASUS_EXPORT SimpleThread |
class PEGASUS_COMMON_LINKAGE SimpleThread |
{ | { |
| |
public: | public: |
|
|
| |
| |
| |
class PEGASUS_EXPORT thread_data |
class PEGASUS_COMMON_LINKAGE thread_data |
{ | { |
| |
public: | public: |
|
|
void *_data; | void *_data; |
size_t _size; | size_t _size; |
Sint8 *_key; | Sint8 *_key; |
|
|
friend class DQueue<thread_data>; | friend class DQueue<thread_data>; |
friend class Thread; | friend class Thread; |
}; | }; |
|
|
| |
/////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////// |
| |
class PEGASUS_EXPORT Thread |
class PEGASUS_COMMON_LINKAGE ThreadPool; |
|
|
|
class PEGASUS_COMMON_LINKAGE Thread |
{ | { |
| |
public: | public: |
|
|
return(NULL); | return(NULL); |
} | } |
| |
|
inline void *try_reference_tsd(Sint8 *key) throw(IPCException) |
|
{ |
|
_tsd.try_lock(); |
|
thread_data *tsd = _tsd.reference((void *)key); |
|
if(tsd != NULL) |
|
return((void *)(tsd->_data) ); |
|
else |
|
return(NULL); |
|
} |
|
|
|
|
// 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) | inline void dereference_tsd(void) throw(IPCException) |
|
|
delete tsd; | delete tsd; |
} | } |
| |
|
inline void *remove_tsd(Sint8 *key) throw(IPCException) |
|
{ |
|
return(_tsd.remove((void *)key)); |
|
} |
|
|
|
inline void empty_tsd(void) throw(IPCException) |
|
{ |
|
_tsd.empty_list(); |
|
} |
|
|
// create or re-initialize tsd associated with the key | // create or re-initialize tsd associated with the key |
// if the tsd already exists, return the existing buffer | // if the tsd already exists, return the existing buffer |
thread_data *put_tsd(Sint8 *key, void (*delete_func)(void *), Uint32 size, void *value) | thread_data *put_tsd(Sint8 *key, void (*delete_func)(void *), Uint32 size, void *value) |
|
|
| |
PEGASUS_THREAD_HANDLE getThreadHandle() {return _handle;} | PEGASUS_THREAD_HANDLE getThreadHandle() {return _handle;} |
| |
|
inline Boolean operator==(const void *key) const |
|
{ |
|
if ( (void *)this == key) |
|
return(true); |
|
return(false); |
|
} |
|
inline Boolean operator==(const Thread & b) const |
|
{ |
|
return(operator==((const void *)&b )); |
|
} |
|
|
private: | private: |
Thread(); | Thread(); |
inline void create_tsd(Sint8 *key ) throw(IPCException) | inline void create_tsd(Sint8 *key ) throw(IPCException) |
|
|
void *_thread_parm; | void *_thread_parm; |
PEGASUS_THREAD_RETURN _exit_code; | PEGASUS_THREAD_RETURN _exit_code; |
static Boolean _signals_blocked; | static Boolean _signals_blocked; |
|
friend class ThreadPool; |
} ; | } ; |
| |
| |
#if 0 |
class PEGASUS_COMMON_LINKAGE ThreadPool |
class PEGASUS_EXPORT Aggregator { |
{ |
|
|
public: | public: |
| |
Aggregator(); |
ThreadPool(Sint16 initial_size, |
~Aggregator(); |
Sint16 max, |
|
Sint16 min, |
|
Sint8 *key); |
|
|
|
~ThreadPool(void); |
|
void allocate_and_awaken(void *parm, |
|
PEGASUS_THREAD_RETURN (PEGASUS_THREAD_CDECL *work)(void *)) |
|
throw(IPCException); |
| |
void started(void); |
void get_key(Sint8 *buf, int bufsize); |
void completed(void); |
|
void remaining(int operations); |
|
void put_result(CIMReference *ref); |
|
| |
private: |
// accessors for min, max, wait |
int _reference_count; |
|
| |
// keep track of the thread running this operation so we can kill |
private: |
// it if necessary |
ThreadPool(void); |
Thread _owner; |
Sint16 _max_threads; |
|
Sint16 _min_threads; |
// this is a phased aggregate. when it is complete is will |
AtomicInt _current_threads; |
// be streamed to the client regardless of the state of |
struct timeval _allocate_wait; |
// siblings |
struct timeval _deallocate_wait; |
Boolean _is_phased; |
struct timeval _deadlock_detect; |
|
static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL _loop(void *); |
int _total_values; |
Semaphore _waiters; |
int _completed_values; |
Sint8 _key[17]; |
int _total_child_values; |
Semaphore _pool_sem; |
int _completed_child_values; |
DQueue<Thread>_pool; |
int _completion_state; |
DQueue<Thread>_running; |
struct timeval _last_update; |
AtomicInt _dying; |
time_t lifetime; |
|
Aggregator *_parent; |
void _kill_dead_threads(DQueue<Thread> *q, Boolean (*check)(struct timeval *)) |
// children may be phased or not phased |
throw(IPCException); |
DQueue _children; |
static void _sleep_sem_del(void *p); |
// empty results that are filled by provider |
static Boolean _check_time(struct timeval *start, struct timeval *interval); |
DQueue _results; |
void _check_deadlock(struct timeval *start) throw(Deadlock); |
// array of predicates for events and |
Boolean _check_deadlock_no_throw(struct timeval *start); |
// stored queries (cursors) |
Boolean _check_dealloc(struct timeval *start); |
Array _filter; |
Thread *_init_thread(void) throw(IPCException); |
|
void _link_pool(Thread *th) throw(IPCException); |
} ; | } ; |
#endif |
|
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |