00001
00002
00003 #include "ace/Semaphore.h"
00004
00005 #if !defined (__ACE_INLINE__)
00006 #include "ace/Semaphore.inl"
00007 #endif
00008
00009 #include "ace/Log_Msg.h"
00010 #include "ace/ACE.h"
00011
00012 ACE_RCSID (ace,
00013 Semaphore,
00014 "Semaphore.cpp,v 4.7 2005/10/28 16:14:55 ossama Exp")
00015
00016 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00017
00018 ACE_ALLOC_HOOK_DEFINE(ACE_Semaphore)
00019
00020 void
00021 ACE_Semaphore::dump (void) const
00022 {
00023
00024
00025 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00026 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\n")));
00027 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00028 }
00029
00030 ACE_Semaphore::ACE_Semaphore (unsigned int count,
00031 int type,
00032 const ACE_TCHAR *name,
00033 void *arg,
00034 int max)
00035 : removed_ (0)
00036 {
00037
00038 #if defined(ACE_LACKS_UNNAMED_SEMAPHORE)
00039
00040 ACE_TCHAR iname[ACE_UNIQUE_NAME_LEN];
00041 if (name == 0)
00042 ACE::unique_name (this, iname, ACE_UNIQUE_NAME_LEN);
00043 if (ACE_OS::sema_init (&this->semaphore_, count, type,
00044 name ? name : iname,
00045 arg, max) != 0)
00046 #else
00047 if (ACE_OS::sema_init (&this->semaphore_, count, type,
00048 name, arg, max) != 0)
00049 #endif
00050 ACE_ERROR ((LM_ERROR,
00051 ACE_LIB_TEXT ("%p\n"),
00052 ACE_LIB_TEXT ("ACE_Semaphore::ACE_Semaphore")));
00053 }
00054
00055 ACE_Semaphore::~ACE_Semaphore (void)
00056 {
00057
00058
00059 this->remove ();
00060 }
00061
00062 ACE_END_VERSIONED_NAMESPACE_DECL