00001 // -*- C++ -*- 00002 // 00003 // Semaphore.inl,v 4.3 2005/10/28 16:14:55 ossama Exp 00004 00005 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00006 00007 ACE_INLINE const ACE_sema_t & 00008 ACE_Semaphore::lock (void) const 00009 { 00010 // ACE_TRACE ("ACE_Semaphore::lock"); 00011 return this->semaphore_; 00012 } 00013 00014 ACE_INLINE int 00015 ACE_Semaphore::remove (void) 00016 { 00017 // ACE_TRACE ("ACE_Semaphore::remove"); 00018 int result = 0; 00019 if (this->removed_ == 0) 00020 { 00021 this->removed_ = 1; 00022 result = ACE_OS::sema_destroy (&this->semaphore_); 00023 } 00024 return result; 00025 } 00026 00027 ACE_INLINE int 00028 ACE_Semaphore::acquire (void) 00029 { 00030 // ACE_TRACE ("ACE_Semaphore::acquire"); 00031 return ACE_OS::sema_wait (&this->semaphore_); 00032 } 00033 00034 ACE_INLINE int 00035 ACE_Semaphore::acquire (ACE_Time_Value &tv) 00036 { 00037 // ACE_TRACE ("ACE_Semaphore::acquire"); 00038 return ACE_OS::sema_wait (&this->semaphore_, tv); 00039 } 00040 00041 ACE_INLINE int 00042 ACE_Semaphore::acquire (ACE_Time_Value *tv) 00043 { 00044 // ACE_TRACE ("ACE_Semaphore::acquire"); 00045 return ACE_OS::sema_wait (&this->semaphore_, tv); 00046 } 00047 00048 ACE_INLINE int 00049 ACE_Semaphore::tryacquire (void) 00050 { 00051 // ACE_TRACE ("ACE_Semaphore::tryacquire"); 00052 return ACE_OS::sema_trywait (&this->semaphore_); 00053 } 00054 00055 ACE_INLINE int 00056 ACE_Semaphore::release (void) 00057 { 00058 // ACE_TRACE ("ACE_Semaphore::release"); 00059 return ACE_OS::sema_post (&this->semaphore_); 00060 } 00061 00062 ACE_INLINE int 00063 ACE_Semaphore::release (unsigned int release_count) 00064 { 00065 // ACE_TRACE ("ACE_Semaphore::release"); 00066 return ACE_OS::sema_post (&this->semaphore_, release_count); 00067 } 00068 00069 // Acquire semaphore ownership. This calls <acquire> and is only 00070 // here to make the <ACE_Semaphore> interface consistent with the 00071 // other synchronization APIs. 00072 00073 ACE_INLINE int 00074 ACE_Semaphore::acquire_read (void) 00075 { 00076 return this->acquire (); 00077 } 00078 00079 // Acquire semaphore ownership. This calls <acquire> and is only 00080 // here to make the <ACE_Semaphore> interface consistent with the 00081 // other synchronization APIs. 00082 00083 ACE_INLINE int 00084 ACE_Semaphore::acquire_write (void) 00085 { 00086 return this->acquire (); 00087 } 00088 00089 // Conditionally acquire semaphore (i.e., won't block). This calls 00090 // <tryacquire> and is only here to make the <ACE_Semaphore> 00091 // interface consistent with the other synchronization APIs. 00092 00093 ACE_INLINE int 00094 ACE_Semaphore::tryacquire_read (void) 00095 { 00096 return this->tryacquire (); 00097 } 00098 00099 // Conditionally acquire semaphore (i.e., won't block). This calls 00100 // <tryacquire> and is only here to make the <ACE_Semaphore> 00101 // interface consistent with the other synchronization APIs. 00102 00103 ACE_INLINE int 00104 ACE_Semaphore::tryacquire_write (void) 00105 { 00106 return this->tryacquire (); 00107 } 00108 00109 // This is only here to make the <ACE_Semaphore> interface consistent 00110 // with the other synchronization APIs. Assumes the caller has 00111 // already acquired the semaphore using one of the above calls, and 00112 // returns 0 (success) always. 00113 ACE_INLINE int 00114 ACE_Semaphore::tryacquire_write_upgrade (void) 00115 { 00116 return 0; 00117 } 00118 00119 ACE_END_VERSIONED_NAMESPACE_DECL