⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ofthread.h

📁 转化为DIB位图再显示出来的dicom文件C++代码
💻 H
📖 第 1 页 / 共 2 页
字号:
 */class OFSemaphore{public:  /** constructor.   *  @param numResources is the initial and maximum value for the semaphore.   */  OFSemaphore(unsigned int numResources);  /** destructor */  ~OFSemaphore();  /** checks whether creation of the object was successful.   *  @return OFTrue if the object was successfully created, OFFalse otherwise.   */  OFBool initialized() const;  /** blocks the calling thread until the semaphore counter is greater than zero   *  and then atomically decreases the counter.   *  @return 0 upon success, an error code otherwise.   */  int wait();  /** atomically decreases the counter if it is larger than zero,   *  otherwise returns OFSemaphore::busy.   *  @return 0 upon success, OFSemaphore::busy if the semaphore is already locked,   *    an error code otherwise.   */  int trywait();  /** atomically increases the counter. If threads are blocked on the semaphore,   *  at least one of them is unblocked.   *  @return 0 upon success, an error code otherwise.   */  int post();  /** converts any of the error codes returned by the methods of this class   *  into a textual description, which is written into the string object.   *  @param description string object into which the error description is written.   *  @param code error code   */  static void errorstr(OFString& description, int code);  /** this constant is returned by the trywait() method if the semaphore   *  is already locked. Since this value is operating system dependent,   *  comparisons should always compare the return value of trywait()   *  with this constant.   */  static const int busy;private:  /** semaphore resource */#ifdef HAVE_CXX_VOLATILE  volatile#endif  void * theSemaphore;  /** unimplemented private copy constructor */  OFSemaphore(const OFSemaphore& arg);  /** unimplemented private assignment operator */  OFSemaphore& operator=(const OFSemaphore& arg);};/** provides an operating system independent abstraction for mutexes *  (mutual exclusion locks). *  Mutexes prevent multiple threads from simultaneously executing critical *  sections of code which access shared data. A successful call for a *  mutex lock by way of lock() will cause another thread that is also *  trying to lock the same mutex to block until the owner thread unlocks *  it by way of unlock(). */class OFMutex{public:  /** default constructor */  OFMutex();  /** destructor */  ~OFMutex();  /** checks whether creation of the object was successful.   *  @return OFTrue if the object was successfully created, OFFalse otherwise.   */  OFBool initialized() const;  /** locks the mutex object. If the mutex is already locked, the calling   *  thread blocks until the mutex is freed; If the current owner of a   *  mutex tries to relock the mutex, it may or may not result in   *  deadlock.   *  @return 0 upon success, an error code otherwise.   */  int lock();  /** tries to lock the mutex object. If the mutex is already locked,   *  returns OFMutex::busy.   *  @return 0 upon success, OFMutex::busy if the mutex is already locked,   *    an error code otherwise.   */  int trylock();  /** releases the lock on the mutex object. The mutex must be locked and   *  the calling thread must be the owner of the lock, otherwise the   *  behaviour is undefined. If there are threads blocked on the mutex   *  when unlock() is called, one of them is unblocked and receives   *  ownership of the mutex lock.   *  @return 0 upon success, an error code otherwise.   */  int unlock();  /** converts any of the error codes returned by the methods of this class   *  into a textual description, which is written into the string object.   *  @param description string object into which the error description is written.   *  @param code error code   */  static void errorstr(OFString& description, int code);  /** this constant is returned by the trylock() method if the mutex   *  is already locked. Since this value is operating system dependent,   *  comparisons should always compare the return value of trylock()   *  with this constant.   */  static const int busy;private:  /** mutex resource */#ifdef HAVE_CXX_VOLATILE  volatile#endif  void * theMutex;  /** unimplemented private copy constructor */  OFMutex(const OFMutex& arg);  /** unimplemented private assignment operator */  OFMutex& operator=(const OFMutex& arg);};/** provides an operating system independent abstraction for read/write *  locks. Many threads can have simultaneous read-only access to data, *  while only one thread can have write access at any given time. *  Multiple read access with single write access is controlled by *  read/write locks, which are generally used to protect data that is *  frequently searched. */class OFReadWriteLock{public:  /** default constructor */  OFReadWriteLock();  /** destructor */  ~OFReadWriteLock();  /** checks whether creation of the object was successful.   *  @return OFTrue if the object was successfully created, OFFalse otherwise.   */  OFBool initialized() const;  /** gets a read lock. If the read/write lock is currently locked for   *  writing, the calling thread blocks until the write lock is freed.   *  Multiple threads may simultaneously hold a read lock on a read/write   *  lock.   *  @return 0 upon success, an error code otherwise.   */  int rdlock();  /** gets a write lock. If the read/write lock is currently locked for   *  reading or writing, the calling thread blocks until all the read and   *  write locks are freed. At any given time, only one thread may have a   *  write lock on a read/write lock.   *  @return 0 upon success, an error code otherwise.   */  int wrlock();  /** trys to get a read lock. If the read/write lock is locked for   *  writing, returns OFReadWriteLock::busy.   *  @return 0 upon success, OFReadWriteLock::busy if the read/write lock   *    is already locked, an error code otherwise.   */  int tryrdlock();  /** trys to get a write lock. If the read/write lock is currently locked   *  for reading or writing, returns OFReadWriteLock::busy.   *  @return 0 upon success, OFReadWriteLock::busy if the read/write lock   *    is already locked, an error code otherwise.   */  int trywrlock();  /** unlocks the read/write lock. The read/write lock must be locked and   *  the calling thread must be the owner of the lock, otherwise the   *  behaviour is undefined. One of the other threads that is waiting for   *  the read/write lock to be freed will be unblocked, provided there are   *  other waiting threads.   *  @return 0 upon success, an error code otherwise.   */  int unlock();  /** converts any of the error codes returned by the methods of this class   *  into a textual description, which is written into the string object.   *  @param description string object into which the error description is written.   *  @param code error code   */  static void errorstr(OFString& description, int code);  /** this constant is returned by the tryrdlock() and trywrlock() methods   *  if the read/write lock is already locked. Since this value is operating   *  system dependent, comparisons should always compare the return value   *  of tryrdlock() and trywrlock() with this constant.   */  static const int busy;private:  /** read/write lock resource */#ifdef HAVE_CXX_VOLATILE  volatile#endif  void * theLock;  /** unimplemented private copy constructor */  OFReadWriteLock(const OFReadWriteLock& arg);  /** unimplemented private assignment operator */  OFReadWriteLock& operator=(const OFReadWriteLock& arg);};#endif/* * * CVS/RCS Log: * $Log: ofthread.h,v $ * Revision 1.9  2005/12/08 16:06:08  meichel * Changed include path schema for all DCMTK header files * * Revision 1.8  2004/08/03 16:44:16  meichel * Updated code to correctly handle pthread_t both as an integral integer type *   (e.g. Linux, Solaris) and as a pointer type (e.g. BSD, OSF/1). * * Revision 1.7  2003/12/05 10:37:41  joergr * Removed leading underscore characters from preprocessor symbols (reserved * symbols). Updated copyright date where appropriate. * * Revision 1.6  2003/07/04 13:29:51  meichel * Replaced forward declarations for OFString with explicit includes, *   needed when compiling with HAVE_STD_STRING * * Revision 1.5  2003/06/06 10:31:04  meichel * Added volatile keyword to data pointers in multi-thread wrapper classes * * Revision 1.4  2002/02/27 14:13:19  meichel * Changed initialized() methods to const. Fixed some return values when *   compiled without thread support. * * Revision 1.3  2001/06/01 15:51:36  meichel * Updated copyright header * * Revision 1.2  2000/06/26 09:27:26  joergr * Replaced _WIN32 by HAVE_WINDOWS_H to avoid compiler errors using CygWin-32. * * Revision 1.1  2000/03/29 16:41:23  meichel * Added new classes providing an operating system independent abstraction *   for threads, thread specific data, semaphores, mutexes and read/write locks. * * */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -