diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-09-20 19:04:19 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-09-20 19:04:19 +0000 |
commit | def086de174f96c1bd93c9078e821d5a87bdf25e (patch) | |
tree | f6362ad44f43a5709aa6dfe1706fbd5e2e47564d /ace/Process_Semaphore.cpp | |
parent | 2dcdd59aa2f7030a0cc42c204003da7762a15743 (diff) | |
download | ATCD-def086de174f96c1bd93c9078e821d5a87bdf25e.tar.gz |
ChangeLogTag:Wed Sep 20 12:00:42 2000 Carlos O'Ryan <coryan@uci.edu>
Diffstat (limited to 'ace/Process_Semaphore.cpp')
-rw-r--r-- | ace/Process_Semaphore.cpp | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/ace/Process_Semaphore.cpp b/ace/Process_Semaphore.cpp new file mode 100644 index 00000000000..ebc036b509b --- /dev/null +++ b/ace/Process_Semaphore.cpp @@ -0,0 +1,91 @@ +// $Id$ + +#include "ace/Process_Semaphore.h" +#include "ace/Log_Msg.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Process_Semaphore.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, Process_Semaphore, "$Id$") + +void +ACE_Process_Semaphore::dump (void) const +{ +// ACE_TRACE ("ACE_Process_Semaphore::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + this->lock_.dump (); + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +} + +ACE_Process_Semaphore::ACE_Process_Semaphore (u_int count, + const ACE_TCHAR *name, + void *arg, + int max) +#if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) || defined (ACE_PSOS) + : lock_ (count, USYNC_PROCESS, name, arg, max) +#else + : lock_ (name, ACE_SV_Semaphore_Complex::ACE_CREATE, count) +#endif /* ACE_WIN32 || ACE_HAS_POSIX_SEM || ACE_PSOS */ +{ + arg = arg; + max = max; +// ACE_TRACE ("ACE_Process_Semaphore::ACE_Process_Semaphore"); +} + +ACE_Process_Semaphore::~ACE_Process_Semaphore (void) +{ + // ACE_TRACE ("ACE_Process_Semaphore::~ACE_Process_Semaphore"); +} + +// Explicitly destroy the semaphore. + +int +ACE_Process_Semaphore::remove (void) +{ +// ACE_TRACE ("ACE_Process_Semaphore::remove"); + return this->lock_.remove (); +} + +// Block the thread until the semaphore count becomes +// greater than 0, then decrement it. + +int +ACE_Process_Semaphore::acquire (void) +{ +// ACE_TRACE ("ACE_Process_Semaphore::acquire"); + return this->lock_.acquire (); +} + +// Conditionally decrement the semaphore if count is greater +// than 0 (i.e., won't block). + +int +ACE_Process_Semaphore::tryacquire (void) +{ +// ACE_TRACE ("ACE_Process_Semaphore::tryacquire"); + return this->lock_.tryacquire (); +} + +// Increment the semaphore, potentially unblocking +// a waiting thread. + +int +ACE_Process_Semaphore::release (void) +{ +// ACE_TRACE ("ACE_Process_Semaphore::release"); + return this->lock_.release (); +} + +// +// These are instantiated both with and without ACE_HAS_THREADS. +// +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +// template class ACE_Guard<ACE_Process_Semaphore>; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +// #pragma instantiate ACE_Guard<ACE_Process_Semaphore> + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ |