Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Token.i

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 // $Id: Token.i,v 1.1.1.3 2003/02/21 18:36:32 chad Exp $
00003 
00004 // Token.i
00005 
00006 ACE_INLINE int
00007 ACE_Token::queueing_strategy (void)
00008 {
00009   return this->queueing_strategy_;
00010 }
00011 
00012 ACE_INLINE void
00013 ACE_Token::queueing_strategy (int queueing_strategy)
00014 {
00015   this->queueing_strategy_ = queueing_strategy == -1 ? -1 : 0;
00016 }
00017 
00018 ACE_INLINE int
00019 ACE_Token::remove (void)
00020 {
00021   ACE_TRACE ("ACE_Token::remove");
00022   // Don't have an implementation for this yet...
00023   ACE_NOTSUP_RETURN (-1);
00024 }
00025 
00026 ACE_INLINE int 
00027 ACE_Token::tryacquire (void)
00028 {
00029   ACE_TRACE ("ACE_Token::tryacquire");
00030   return this->shared_acquire 
00031     (0, 0, (ACE_Time_Value *) &ACE_Time_Value::zero, ACE_Token::WRITE_TOKEN);
00032 }
00033 
00034 ACE_INLINE int 
00035 ACE_Token::waiters (void)
00036 {
00037   ACE_TRACE ("ACE_Token::waiters");
00038   ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1);
00039 
00040   int ret = this->waiters_;
00041   return ret;
00042 }
00043 
00044 ACE_INLINE ACE_thread_t 
00045 ACE_Token::current_owner (void)
00046 {
00047   ACE_TRACE ("ACE_Token::current_owner");
00048   ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, this->owner_);
00049 
00050   return this->owner_;
00051 }
00052 
00053 ACE_INLINE int
00054 ACE_Token::acquire_read (void)
00055 {
00056   ACE_TRACE ("ACE_Token::acquire_read");
00057   return this->shared_acquire
00058     (0, 0, 0, ACE_Token::READ_TOKEN);
00059 }
00060 
00061 ACE_INLINE int
00062 ACE_Token::acquire_write (void)
00063 {
00064   ACE_TRACE ("ACE_Token::acquire_write");
00065   return this->shared_acquire
00066     (0, 0, 0, ACE_Token::WRITE_TOKEN);
00067 }
00068 
00069 ACE_INLINE int
00070 ACE_Token::tryacquire_read (void)
00071 {
00072   ACE_TRACE ("ACE_Token::tryacquire_read");
00073   return this->shared_acquire
00074     (0, 0, (ACE_Time_Value *) &ACE_Time_Value::zero, ACE_Token::READ_TOKEN);
00075 }
00076 
00077 ACE_INLINE int
00078 ACE_Token::acquire_read (void (*sleep_hook_func)(void *),
00079                          void *arg,
00080                          ACE_Time_Value *timeout)
00081 {
00082   ACE_TRACE ("ACE_Token::acquire_read");
00083   return this->shared_acquire (sleep_hook_func, arg, timeout, ACE_Token::READ_TOKEN);
00084 }
00085 
00086 ACE_INLINE int
00087 ACE_Token::tryacquire_write (void)
00088 {
00089   ACE_TRACE ("ACE_Token::tryacquire_write");
00090   return this->shared_acquire
00091     (0, 0, (ACE_Time_Value *) &ACE_Time_Value::zero, ACE_Token::WRITE_TOKEN);
00092 }
00093 
00094 ACE_INLINE int
00095 ACE_Token::tryacquire_write_upgrade (void)
00096 {
00097   ACE_TRACE ("ACE_Token::tryacquire_write_upgrade");
00098   return 0;
00099 }
00100 
00101 ACE_INLINE int
00102 ACE_Token::acquire_write (void (*sleep_hook_func)(void *),
00103                           void *arg,
00104                           ACE_Time_Value *timeout)
00105 {
00106   ACE_TRACE ("ACE_Token::acquire_write");
00107   return this->shared_acquire (sleep_hook_func, arg, timeout, ACE_Token::WRITE_TOKEN);
00108 }
00109 
00110 ACE_INLINE int
00111 ACE_Token::ACE_Token_Queue_Entry::wait (ACE_Time_Value *timeout, ACE_Thread_Mutex &lock)
00112 {
00113 #if defined (ACE_TOKEN_USES_SEMAPHORE)
00114   lock.release ();
00115   int retv = (timeout == 0 ?
00116               this->cv_.acquire () :
00117               this->cv_.acquire (*timeout));
00118   lock.acquire ();
00119   return retv;
00120 #else
00121   ACE_UNUSED_ARG (lock);
00122   return this->cv_.wait (timeout);
00123 #endif /* ACE_TOKEN_USES_SEMAPHORE */
00124 }
00125 
00126 ACE_INLINE int
00127 ACE_Token::ACE_Token_Queue_Entry::signal (void)
00128 {
00129   return 
00130 #if defined (ACE_TOKEN_USES_SEMAPHORE)
00131     this->cv_.release ();
00132 #else
00133     this->cv_.signal ();
00134 #endif /* ACE_TOKEN_USES_SEMAPHORE */
00135 }

Generated on Mon Jun 16 11:21:56 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002