omnithread library
Weicong Wang
weicong@caip.rutgers.edu
Tue, 27 May 1997 10:31:54 -0500
I think you could look into the Fresco thread library, it seems that
they have some similar ideas.
The fresco could be found in
http://www.caip.rutgers.edu/multimedia/Fresco/
===================
Brian Burton wrote:
> I'm porting the omnithread library to BeOS (http://www.be.com) and
> noticied that there are no classes in the omnithread.h file for
> acquiring and releasing mutexes and semaphores. These really should
> be
> added since they would be far more convenient and less error prone
> than
> calling lock()/unlock() directly. For example:
>
> class omni_mutex_lock
> {
> public:
> omni_mutex_lock(omni_mutex *mutex)
> : _mutex(mutex)
> {
> _mutex->lock();
> }
> ~omni_mutex_lock()
> {
> _mutex->unlock();
> }
> private:
> omni_mutex *_mutex;
> };
>
> A similar class could be added for semaphores (possibly with an
> overloaded constructor for doing a try_wait).
>
> With a class such as this, a mutex lock can be acquired and released
> by
> simply defining a variable of the omni_mutex_lock class:
>
> omni_mutex mutex;
>
> ...
>
> int some_class::some_function()
> {
> omni_mutex_lock lock(&mutex);
> if (some_flag)
> return -1;
> do_something_that_might_throw_exception();
> return 0;
> }
>
> The lock object's destructor would automatically unlock the mutex when
>
> the return statements are executed and when an exception is
> encountered.
>
> Are there already helper classes like this specified in another
> header?
> If not, then they should probably be added to omnithread.h to provide
> a
> standard version.
>
> All the best,
> ++Brian
>
> --
> Brian Burton Custom Software Development
> Burton Computer Corporation Java, C++, Orbix, Tuxedo
> brian.burton@burton-computer.com OO Consulting and Mentoring
--
======================================================
Wang Weicong Rutgers, the State Univ. of New Jersey
------------------------------------------------------
CAIP Center, PO Box 1390
Piscataway , NJ 08855-1390
------------------------------------------------------
Tel: (O) 908-445-0659/0660 (H) 908-878-2734
http://www.caip.rutgers.edu/~weicong
------------------------------------------------------