Sha256: 23e18ee900cdcd8af38f306d7dbffeaeff4eb65eb123e4eb7ce8a13b3d803825
Contents?: true
Size: 1.97 KB
Versions: 13
Compression:
Stored size: 1.97 KB
Contents
// Copyright (C) 2006 Davis E. King (davis@dlib.net) // License: Boost Software License See LICENSE.txt for the full license. #ifndef DLIB_RSIGNALER_EXTENSIOn_ #define DLIB_RSIGNALER_EXTENSIOn_ #include "rsignaler_extension_abstract.h" #include "rmutex_extension.h" namespace dlib { // ---------------------------------------------------------------------------------------- class rsignaler { public: rsignaler ( const rmutex& associated_mutex ) : assoc_mutex(associated_mutex), s(m) {} ~rsignaler ( ) {} void wait ( ) const { m.lock(); const unsigned long lock_count = assoc_mutex.lock_count(); assoc_mutex.unlock(lock_count); s.wait(); m.unlock(); assoc_mutex.lock(lock_count); } bool wait_or_timeout ( unsigned long milliseconds ) const { m.lock(); const unsigned long lock_count = assoc_mutex.lock_count(); assoc_mutex.unlock(lock_count); bool res = s.wait_or_timeout(milliseconds); m.unlock(); assoc_mutex.lock(lock_count); return res; } void signal ( ) const { m.lock(); s.signal(); m.unlock(); } void broadcast ( ) const { m.lock(); s.broadcast(); m.unlock(); } const rmutex& get_mutex ( ) const { return assoc_mutex; } private: const rmutex& assoc_mutex; mutex m; signaler s; // restricted functions rsignaler(rsignaler&); // copy constructor rsignaler& operator=(rsignaler&); // assignment operator }; // ---------------------------------------------------------------------------------------- } #endif // DLIB_RSIGNALER_EXTENSIOn_
Version data entries
13 entries across 13 versions & 1 rubygems