(file) Return to Thread.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/Thread.h between version 1.42 and 1.43

version 1.42, 2004/10/17 20:39:17 version 1.43, 2005/01/16 03:03:10
Line 30 
Line 30 
 // Modified By: Markus Mueller // Modified By: Markus Mueller
 //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 //              Amit K Arora, IBM (amita@in.ibm.com) for PEP#101 //              Amit K Arora, IBM (amita@in.ibm.com) for PEP#101
   //              David Dillard, VERITAS Software Corp.
   //                  (david.dillard@veritas.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 83 
Line 85 
    public:    public:
       static void default_delete(void *data);       static void default_delete(void *data);
  
       thread_data( const Sint8 *key ) : _delete_func(NULL) , _data(NULL), _size(0)        thread_data( const char *key ) : _delete_func(NULL) , _data(NULL), _size(0)
       {       {
          PEGASUS_ASSERT(key != NULL);          PEGASUS_ASSERT(key != NULL);
          size_t keysize = strlen(key);          size_t keysize = strlen(key);
          _key = new Sint8 [keysize + 1];           _key = new char[keysize + 1];
          memcpy(_key, key, keysize);          memcpy(_key, key, keysize);
          _key[keysize] = 0x00;          _key[keysize] = 0x00;
  
       }       }
  
       thread_data(const Sint8 *key, size_t size) : _delete_func(default_delete), _size(size)        thread_data(const char *key, size_t size) : _delete_func(default_delete), _size(size)
       {       {
          PEGASUS_ASSERT(key != NULL);          PEGASUS_ASSERT(key != NULL);
          size_t keysize = strlen(key);          size_t keysize = strlen(key);
          _key = new Sint8 [keysize + 1];           _key = new char[keysize + 1];
          memcpy(_key, key, keysize);          memcpy(_key, key, keysize);
          _key[keysize] = 0x00;          _key[keysize] = 0x00;
          _data = ::operator new(_size) ;          _data = ::operator new(_size) ;
  
       }       }
  
       thread_data(const Sint8 *key, size_t size, void *data) : _delete_func(default_delete), _size(size)        thread_data(const char *key, size_t size, void *data) : _delete_func(default_delete), _size(size)
       {       {
          PEGASUS_ASSERT(key != NULL);          PEGASUS_ASSERT(key != NULL);
          PEGASUS_ASSERT(data != NULL);          PEGASUS_ASSERT(data != NULL);
          size_t keysize = strlen(key);          size_t keysize = strlen(key);
  
          _key = new Sint8[keysize + 1];           _key = new char[keysize + 1];
          memcpy(_key, key, keysize);          memcpy(_key, key, keysize);
          _key[keysize] = 0x00;          _key[keysize] = 0x00;
          _data = ::operator new(_size);          _data = ::operator new(_size);
Line 188 
Line 190 
  
       inline Boolean operator==(const void *key) const       inline Boolean operator==(const void *key) const
       {       {
          if ( ! strcmp(_key, (Sint8 *)key))           if ( ! strcmp(_key, reinterpret_cast<const char *>(key)))
             return(true);             return(true);
          return(false);          return(false);
       }       }
  
       inline Boolean operator==(const thread_data& b) const       inline Boolean operator==(const thread_data& b) const
       {       {
          return(operator==((const void *)b._key));           return(operator==(b._key));
       }       }
  
    private:    private:
Line 203 
Line 205 
       thread_data();       thread_data();
       void *_data;       void *_data;
       size_t _size;       size_t _size;
       Sint8 *_key;        char *_key;
  
       friend class DQueue<thread_data>;       friend class DQueue<thread_data>;
       friend class Thread;       friend class Thread;
Line 282 
Line 284 
       void cleanup_pop(Boolean execute = true) throw(IPCException);       void cleanup_pop(Boolean execute = true) throw(IPCException);
  
       // create and initialize a tsd       // create and initialize a tsd
       inline void create_tsd(const Sint8 *key, int size, void *buffer) throw(IPCException)        inline void create_tsd(const char *key, int size, void *buffer) throw(IPCException)
       {       {
         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());
Line 291 
Line 293 
  
       // 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 Sint8 *key) throw(IPCException)        inline void *reference_tsd(const char *key) throw(IPCException)
       {       {
          _tsd.lock();          _tsd.lock();
          thread_data *tsd = _tsd.reference((const void *)key);           thread_data *tsd = _tsd.reference(key);
          if(tsd != NULL)          if(tsd != NULL)
             return( (void *)(tsd->_data) );             return( (void *)(tsd->_data) );
          else          else
             return(NULL);             return(NULL);
       }       }
  
       inline void *try_reference_tsd(const Sint8 *key) throw(IPCException)        inline void *try_reference_tsd(const char *key) throw(IPCException)
       {       {
          _tsd.try_lock();          _tsd.try_lock();
          thread_data *tsd = _tsd.reference((const void *)key);           thread_data *tsd = _tsd.reference(key);
          if(tsd != NULL)          if(tsd != NULL)
             return((void *)(tsd->_data) );             return((void *)(tsd->_data) );
          else          else
Line 320 
Line 322 
       }       }
  
       // delete the tsd associated with the key       // delete the tsd associated with the key
       inline void delete_tsd(const Sint8 *key) throw(IPCException)        inline void delete_tsd(const char *key) throw(IPCException)
       {       {
          AutoPtr<thread_data> tsd(_tsd.remove((const void *)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 Sint8 *key) throw(IPCException)        inline void *remove_tsd(const char *key) throw(IPCException)
       {       {
          return(_tsd.remove((const void *)key));          return(_tsd.remove((const void *)key));
       }       }
Line 355 
Line 357 
  
       // 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
       void put_tsd(const Sint8 *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)          throw(IPCException)
  
       {       {
Line 428 
Line 430 
  
       static Sint8 initializeKey();  // l10n       static Sint8 initializeKey();  // l10n
  
       inline void create_tsd(const Sint8 *key ) throw(IPCException)        inline void create_tsd(const char *key ) throw(IPCException)
       {       {
          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());
Line 463 
Line 465 
    public:    public:
  
       ThreadPool(Sint16 initial_size,       ThreadPool(Sint16 initial_size,
                  const Sint8 *key,                   const char *key,
                  Sint16 min,                  Sint16 min,
                  Sint16 max,                  Sint16 max,
                  struct timeval & alloc_wait,                  struct timeval & alloc_wait,
Line 496 
Line 498 
  
       void get_key(Sint8 *buf, int bufsize);       void get_key(Sint8 *buf, int bufsize);
  
       inline Boolean operator==(const void *key) const        inline Boolean operator==(const char *key) const
       {       {
          if ( ! strncmp( reinterpret_cast<Sint8 *>(const_cast<void *>(key)), _key, 16  ))           if ( ! strncmp(key, _key, 16))
             return(true);             return(true);
          return(false);          return(false);
       }       }
       inline Boolean operator==(const ThreadPool & b) const       inline Boolean operator==(const ThreadPool & b) const
       {       {
          return(operator==((const void *) b._key ));           return(operator==(b._key));
       }       }
  
       inline void set_min_threads(Sint16 min)       inline void set_min_threads(Sint16 min)
Line 603 
Line 605 
       struct timeval _deallocate_wait;       struct timeval _deallocate_wait;
       struct timeval _deadlock_detect;       struct timeval _deadlock_detect;
       static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL _loop(void *);       static PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL _loop(void *);
       Sint8 _key[17];        char _key[17];
       DQueue<Thread> _pool;       DQueue<Thread> _pool;
       DQueue<Thread> _running;       DQueue<Thread> _running;
       DQueue<Thread> _dead;       DQueue<Thread> _dead;


Legend:
Removed from v.1.42  
changed lines
  Added in v.1.43

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2