00001
00002
00003
00004
00005 #include "ace/config-macros.h"
00006
00007 #if defined (ACE_HAS_THREADS)
00008
00009 #include "ace/Guard_T.h"
00010 #include "ace/Time_Value.h"
00011
00012 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00013
00014 ACE_INLINE int
00015 ACE_Token::queueing_strategy (void)
00016 {
00017 return this->queueing_strategy_;
00018 }
00019
00020 ACE_INLINE void
00021 ACE_Token::queueing_strategy (int queueing_strategy)
00022 {
00023 this->queueing_strategy_ = queueing_strategy == -1 ? -1 : 0;
00024 }
00025
00026 ACE_INLINE int
00027 ACE_Token::remove (void)
00028 {
00029 ACE_TRACE ("ACE_Token::remove");
00030
00031 ACE_NOTSUP_RETURN (-1);
00032 }
00033
00034 ACE_INLINE int
00035 ACE_Token::tryacquire (void)
00036 {
00037 ACE_TRACE ("ACE_Token::tryacquire");
00038 return this->shared_acquire
00039 (0, 0, (ACE_Time_Value *) &ACE_Time_Value::zero, ACE_Token::WRITE_TOKEN);
00040 }
00041
00042 ACE_INLINE int
00043 ACE_Token::waiters (void)
00044 {
00045 ACE_TRACE ("ACE_Token::waiters");
00046 ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1);
00047
00048 int const ret = this->waiters_;
00049 return ret;
00050 }
00051
00052 ACE_INLINE ACE_thread_t
00053 ACE_Token::current_owner (void)
00054 {
00055 ACE_TRACE ("ACE_Token::current_owner");
00056 ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, this->owner_);
00057
00058 return this->owner_;
00059 }
00060
00061 ACE_INLINE int
00062 ACE_Token::acquire_read (void)
00063 {
00064 ACE_TRACE ("ACE_Token::acquire_read");
00065 return this->shared_acquire
00066 (0, 0, 0, ACE_Token::READ_TOKEN);
00067 }
00068
00069 ACE_INLINE int
00070 ACE_Token::acquire_write (void)
00071 {
00072 ACE_TRACE ("ACE_Token::acquire_write");
00073 return this->shared_acquire
00074 (0, 0, 0, ACE_Token::WRITE_TOKEN);
00075 }
00076
00077 ACE_INLINE int
00078 ACE_Token::tryacquire_read (void)
00079 {
00080 ACE_TRACE ("ACE_Token::tryacquire_read");
00081 return this->shared_acquire
00082 (0, 0, (ACE_Time_Value *) &ACE_Time_Value::zero, ACE_Token::READ_TOKEN);
00083 }
00084
00085 ACE_INLINE int
00086 ACE_Token::acquire_read (void (*sleep_hook_func)(void *),
00087 void *arg,
00088 ACE_Time_Value *timeout)
00089 {
00090 ACE_TRACE ("ACE_Token::acquire_read");
00091 return this->shared_acquire (sleep_hook_func, arg, timeout, ACE_Token::READ_TOKEN);
00092 }
00093
00094 ACE_INLINE int
00095 ACE_Token::tryacquire_write (void)
00096 {
00097 ACE_TRACE ("ACE_Token::tryacquire_write");
00098 return this->shared_acquire
00099 (0, 0, (ACE_Time_Value *) &ACE_Time_Value::zero, ACE_Token::WRITE_TOKEN);
00100 }
00101
00102 ACE_INLINE int
00103 ACE_Token::tryacquire_write_upgrade (void)
00104 {
00105 ACE_TRACE ("ACE_Token::tryacquire_write_upgrade");
00106 return 0;
00107 }
00108
00109 ACE_INLINE int
00110 ACE_Token::acquire_write (void (*sleep_hook_func)(void *),
00111 void *arg,
00112 ACE_Time_Value *timeout)
00113 {
00114 ACE_TRACE ("ACE_Token::acquire_write");
00115 return this->shared_acquire (sleep_hook_func, arg, timeout, ACE_Token::WRITE_TOKEN);
00116 }
00117
00118 ACE_INLINE int
00119 ACE_Token::ACE_Token_Queue_Entry::wait (ACE_Time_Value *timeout, ACE_Thread_Mutex &lock)
00120 {
00121 #if defined (ACE_TOKEN_USES_SEMAPHORE)
00122 lock.release ();
00123 int const retv = (timeout == 0 ?
00124 this->cv_.acquire () :
00125 this->cv_.acquire (*timeout));
00126 lock.acquire ();
00127 return retv;
00128 #else
00129 ACE_UNUSED_ARG (lock);
00130 return this->cv_.wait (timeout);
00131 #endif
00132 }
00133
00134 ACE_INLINE int
00135 ACE_Token::ACE_Token_Queue_Entry::signal (void)
00136 {
00137 return
00138 #if defined (ACE_TOKEN_USES_SEMAPHORE)
00139 this->cv_.release ();
00140 #else
00141 this->cv_.signal ();
00142 #endif
00143 }
00144
00145 ACE_END_VERSIONED_NAMESPACE_DECL
00146
00147 #endif
00148
00149
00150
00151 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00152
00153 ACE_INLINE int
00154 ACE_Noop_Token::queueing_strategy (void)
00155 {
00156 return -1;
00157 }
00158
00159 ACE_INLINE void
00160 ACE_Noop_Token::queueing_strategy (int )
00161 {
00162 }
00163
00164 ACE_INLINE int
00165 ACE_Noop_Token::renew (int, ACE_Time_Value *)
00166 {
00167 return 0;
00168 }
00169
00170 ACE_INLINE void
00171 ACE_Noop_Token::dump (void) const
00172 {
00173 }
00174
00175 ACE_END_VERSIONED_NAMESPACE_DECL
00176