2 #include "ace/config-macros.h"
4 #if defined (ACE_HAS_THREADS)
6 #include "ace/Guard_T.h"
7 #include "ace/Time_Value.h"
9 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
12 ACE_Token::queueing_strategy ()
14 return this->queueing_strategy_;
18 ACE_Token::queueing_strategy (int queueing_strategy)
20 this->queueing_strategy_ = queueing_strategy == -1 ? -1 : 0;
26 ACE_TRACE ("ACE_Token::remove");
27 // Don't have an implementation for this yet...
28 ACE_NOTSUP_RETURN (-1);
32 ACE_Token::tryacquire ()
34 ACE_TRACE ("ACE_Token::tryacquire");
35 return this->shared_acquire
36 (0, 0, (ACE_Time_Value *) &ACE_Time_Value::zero, ACE_Token::WRITE_TOKEN);
42 ACE_TRACE ("ACE_Token::waiters");
43 ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1);
45 int const ret = this->waiters_;
49 ACE_INLINE ACE_thread_t
50 ACE_Token::current_owner ()
52 ACE_TRACE ("ACE_Token::current_owner");
53 ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, this->owner_);
59 ACE_Token::acquire_read ()
61 ACE_TRACE ("ACE_Token::acquire_read");
62 return this->shared_acquire
63 (0, 0, 0, ACE_Token::READ_TOKEN);
67 ACE_Token::acquire_write ()
69 ACE_TRACE ("ACE_Token::acquire_write");
70 return this->shared_acquire
71 (0, 0, 0, ACE_Token::WRITE_TOKEN);
75 ACE_Token::tryacquire_read ()
77 ACE_TRACE ("ACE_Token::tryacquire_read");
78 return this->shared_acquire
79 (0, 0, (ACE_Time_Value *) &ACE_Time_Value::zero, ACE_Token::READ_TOKEN);
83 ACE_Token::acquire_read (void (*sleep_hook_func)(void *),
85 ACE_Time_Value *timeout)
87 ACE_TRACE ("ACE_Token::acquire_read");
88 return this->shared_acquire (sleep_hook_func, arg, timeout, ACE_Token::READ_TOKEN);
92 ACE_Token::tryacquire_write ()
94 ACE_TRACE ("ACE_Token::tryacquire_write");
95 return this->shared_acquire
96 (0, 0, (ACE_Time_Value *) &ACE_Time_Value::zero, ACE_Token::WRITE_TOKEN);
100 ACE_Token::tryacquire_write_upgrade ()
102 ACE_TRACE ("ACE_Token::tryacquire_write_upgrade");
107 ACE_Token::acquire_write (void (*sleep_hook_func)(void *),
109 ACE_Time_Value *timeout)
111 ACE_TRACE ("ACE_Token::acquire_write");
112 return this->shared_acquire (sleep_hook_func, arg, timeout, ACE_Token::WRITE_TOKEN);
116 ACE_Token::ACE_Token_Queue_Entry::wait (ACE_Time_Value *timeout, ACE_Thread_Mutex &lock)
118 #if defined (ACE_TOKEN_USES_SEMAPHORE)
120 int const retv = (timeout == 0 ?
121 this->cv_.acquire () :
122 this->cv_.acquire (*timeout));
126 ACE_UNUSED_ARG (lock);
127 return this->cv_.wait (timeout);
128 #endif /* ACE_TOKEN_USES_SEMAPHORE */
132 ACE_Token::ACE_Token_Queue_Entry::signal ()
135 #if defined (ACE_TOKEN_USES_SEMAPHORE)
136 this->cv_.release ();
139 #endif /* ACE_TOKEN_USES_SEMAPHORE */
142 ACE_END_VERSIONED_NAMESPACE_DECL
144 #endif /* ACE_HAS_THREADS */
146 /*****************************************************************************/
148 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
151 ACE_Noop_Token::queueing_strategy ()
157 ACE_Noop_Token::queueing_strategy (int /* queueing_strategy */)
162 ACE_Noop_Token::renew (int, ACE_Time_Value *)
168 ACE_Noop_Token::dump () const
172 ACE_END_VERSIONED_NAMESPACE_DECL