ACE_Token_Proxy Class Reference

Abstract representation of ACE tokens. More...

#include <Local_Tokens.h>

Inheritance diagram for ACE_Token_Proxy:

Inheritance graph
[legend]
Collaboration diagram for ACE_Token_Proxy:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_Token_Proxy (void)
 Construction.

virtual ~ACE_Token_Proxy (void)
 Destructor.

virtual int open (const ACE_TCHAR *name, int ignore_deadlock=0, int debug=0)
virtual int acquire (int notify=0, void(*sleep_hook)(void *)=0, ACE_Synch_Options &options=ACE_Synch_Options::defaults)
virtual int renew (int requeue_position=-1, ACE_Synch_Options &options=ACE_Synch_Options::defaults)
 Calls renew on the token. Blocks the calling thread if would block.

virtual int tryacquire (void(*sleep_hook)(void *)=0)
 Calls renew on the token.

virtual int release (ACE_Synch_Options &options=ACE_Synch_Options::defaults)
 Calls release on the token.

virtual int remove (ACE_Synch_Options &options=ACE_Synch_Options::defaults)
 Calls remove on the token.

virtual int acquire_read (int notify=0, void(*sleep_hook)(void *)=0, ACE_Synch_Options &options=ACE_Synch_Options::defaults)
virtual int acquire_write (int notify=0, void(*sleep_hook)(void *)=0, ACE_Synch_Options &options=ACE_Synch_Options::defaults)
virtual int tryacquire_read (void(*sleep_hook)(void *)=0)
virtual int tryacquire_write (void(*sleep_hook)(void *)=0)
virtual const ACE_TCHARclient_id (void) const
virtual void client_id (const ACE_TCHAR *client_id)
virtual const ACE_TCHARname (void) const
virtual void sleep_hook (void)
virtual void token_acquired (ACE_TPQ_Entry *)
virtual const ACE_TCHARowner_id (void)
 The client id of the current token holder.

virtual ACE_Token_Proxyclone (void) const=0
 Return a dynamically allocated clone of the derived class.

void dump (void) const
 Dump the state of the class.

virtual int type (void) const

Protected Member Functions

 ACE_Token_Proxy (const ACE_Token_Proxy &)
 Duplication.

int handle_options (ACE_Synch_Options &options, ACE_TOKEN_CONST::COND_VAR &cv)
 Handles cond_var waits.

virtual ACE_Tokenscreate_token (const ACE_TCHAR *name)=0

Protected Attributes

int ignore_deadlock_
 If this is set, we ignore deadlock.

int debug_
 Print a bunch of debug messages.

ACE_Tokenstoken_
ACE_TSS_TPQ_Entry waiter_
 Waiter info used for asynchronous transactions.


Friends

class ACE_Token_Manager
class ACE_Token_Invariant_Manager

Detailed Description

Abstract representation of ACE tokens.

Interface for all Tokens in ACE. This class implements the synchronization needed for tokens (condition variables etc.) The algorithms for the operations (acquire, release, etc.) operate on the generic ACE_Tokens interface. Thus, the _type_ of token (mutex, rwlock) can be set at construction of ACE_Token_Proxy. You can use all Tokens in ACE through the ACE_Token_Proxy by passing the proper values at construction. Alternatively, there are class definitions which "know" how to do this (ACE_Local_Mutex, ACE_Local_RLock, ACE_Local_WLock). To add a new type of token (e.g. semaphore), this class is not changed. See ACE_Token_Manager for details. Tokens (e.g. ACE_Mutex_Token) assume that it can always call <ACE_Token_Proxy::token_acquired> on a new token owner. This is not a problem for synchronous use of token proxies (that is, when acquires block until successful.) However, for implementations of the Token Server, which may use asynch operations, the proxy can not go away after an acquire until the token is acquired. This is not really a problem, but should be understood.

Definition at line 751 of file Local_Tokens.h.


Constructor & Destructor Documentation

ACE_Token_Proxy::ACE_Token_Proxy void   ) 
 

Construction.

Definition at line 1144 of file Local_Tokens.cpp.

References ACE_TRACE.

01145 : token_ (0),
01146   waiter_ (this, 0)
01147 {
01148   ACE_TRACE ("ACE_Token_Proxy::ACE_Token_Proxy");
01149 }

ACE_Token_Proxy::~ACE_Token_Proxy void   )  [virtual]
 

Destructor.

Definition at line 1163 of file Local_Tokens.cpp.

References ACE_TRACE, ACE_Token_Manager::instance(), and ACE_Token_Manager::release_token().

01164 {
01165   ACE_TRACE ("ACE_Token_Proxy::~ACE_Token_Proxy");
01166 
01167   if (token_ != 0)
01168     // notify token manager that we are done with it so it can
01169     // free it if necessary
01170     ACE_Token_Manager::instance ()->release_token (token_);
01171 }

ACE_Token_Proxy::ACE_Token_Proxy const ACE_Token_Proxy  )  [protected]
 

Duplication.

Definition at line 1155 of file Local_Tokens.cpp.

References ACE_TRACE.

01156   : token_ (0),
01157     waiter_ (this, 0)
01158 {
01159   ACE_TRACE ("ACE_Token_Proxy::ACE_Token_Proxy");
01160 }


Member Function Documentation

int ACE_Token_Proxy::acquire int  notify = 0,
void(*  sleep_hook)(void *) = 0,
ACE_Synch_Options options = ACE_Synch_Options::defaults
[virtual]
 

Calls acquire on the token. Blocks the calling thread if would block.

Reimplemented in ACE_Null_Token, ACE_Remote_Token_Proxy, and ACE_Token_Collection.

Definition at line 1210 of file Local_Tokens.cpp.

References ACE_DEBUG, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_RETURN, ACE_TRACE, ACE_Tokens::acquire(), ACE_Null_Mutex::acquire(), ACE_TPQ_Entry::cond_var_, EDEADLK, EWOULDBLOCK, handle_options(), ignore_deadlock_, LM_DEBUG, LM_ERROR, ACE_Null_Condition::mutex(), ACE_Tokens::no_of_waiters(), ACE_Tokens::owner_id(), ACE_Null_Mutex::release(), ACE_TPQ_Entry::sleep_hook(), and waiter_.

Referenced by ACE_Token_Collection::acquire(), ACE_Remote_Token_Proxy::acquire(), acquire_read(), and acquire_write().

01213 {
01214   ACE_TRACE ("ACE_Token_Proxy::acquire");
01215   if (this->token_ == 0)
01216     {
01217       errno = ENOENT;
01218       ACE_ERROR_RETURN ((LM_ERROR, ACE_LIB_TEXT ("Not open.\n")), -1);
01219     }
01220 
01221   // Make sure no one calls our token_acquired until we have a chance
01222   // to sleep first!  If after we call an EWOULDBLOCK
01223   // mutex_->acquire() below, but before we enter handle_options to
01224   // wait on the cond_var, a thread tries to give take us off the
01225   // waiter queue and signal us, IT WILL FIRST HAVE TO ACQUIRE THIS
01226   // cond_var.mutex ().  _This_ is why we acquire it.
01227   this->waiter_->cond_var_.mutex ().acquire ();
01228 
01229   this->waiter_->sleep_hook (sleep_hook);
01230 
01231   if (this->token_->acquire (this->waiter_, this->ignore_deadlock_, notify) == -1)
01232     // acquire failed
01233     {
01234       switch (errno)
01235         {
01236         case EDEADLK :
01237           if (!ignore_deadlock_)
01238             {
01239               waiter_->cond_var_.mutex ().release ();
01240               errno = EDEADLK;
01241               ACE_RETURN (-1);
01242             }
01243           // Else, fallthrough and block!
01244 
01245         case EWOULDBLOCK :
01246           if (this->debug_)
01247             ACE_DEBUG ((LM_DEBUG,
01248                         ACE_LIB_TEXT ("(%t) waiting for %s, owner is %s, ")
01249                         ACE_LIB_TEXT ("total waiters == %d\n"),
01250                         this->name (),
01251                         this->token_->owner_id (),
01252                         token_->no_of_waiters ()));
01253 
01254           // no error, but would block, if error, return error (-1),
01255           // otherwise, return whether we called the holder or not.
01256           int return_value;
01257           if (this->handle_options (options,
01258                                     waiter_->cond_var_) == -1)
01259             return_value = -1;
01260           else
01261             return_value = notify == 1;
01262 
01263           errno = EWOULDBLOCK;
01264           ACE_RETURN (return_value);
01265 
01266         default :
01267           waiter_->cond_var_.mutex ().release ();
01268           ACE_ERROR_RETURN ((LM_ERROR,
01269                              ACE_LIB_TEXT ("%p\n"),
01270                              ACE_LIB_TEXT ("Token Proxy acquire.")),
01271                             -1);
01272         }
01273     }
01274   else
01275     // we have the token
01276     {
01277       if (debug_)
01278         ACE_DEBUG ((LM_DEBUG,
01279                     ACE_LIB_TEXT ("(%t) acquired %s\n"),
01280                     this->name ()));
01281       waiter_->cond_var_.mutex ().release ();
01282     }
01283 
01284   return 0;
01285 }

int ACE_Token_Proxy::acquire_read int  notify = 0,
void(*  sleep_hook)(void *) = 0,
ACE_Synch_Options options = ACE_Synch_Options::defaults
[virtual]
 

Since the locking mechanism doesn't support read locks then this just calls .

Definition at line 1457 of file Local_Tokens.cpp.

References acquire().

01460 {
01461   return this->acquire (notify,
01462                         sleep_hook,
01463                         options);
01464 }

int ACE_Token_Proxy::acquire_write int  notify = 0,
void(*  sleep_hook)(void *) = 0,
ACE_Synch_Options options = ACE_Synch_Options::defaults
[virtual]
 

Since the locking mechanism doesn't support write locks then this just calls .

Definition at line 1467 of file Local_Tokens.cpp.

References acquire().

01470 {
01471   return this->acquire (notify,
01472                         sleep_hook,
01473                         options);
01474 }

void ACE_Token_Proxy::client_id const ACE_TCHAR client_id  )  [virtual]
 

Set the client_id for the calling thread. I strongly recommend that this not be used unless you really know what you're doing. I use this in the Token Server, and it caused many headaches.

Definition at line 1124 of file Local_Tokens.cpp.

References ACE_TCHAR, ACE_TRACE, ACE_TPQ_Entry::client_id(), and waiter_.

01125 {
01126   ACE_TRACE ("ACE_Token_Proxy::client_id");
01127   this->waiter_->client_id (client_id);
01128 }

const ACE_TCHAR * ACE_Token_Proxy::client_id void   )  const [virtual]
 

Get the client id of the proxy. This is implemented as thread-specific data.

Definition at line 1110 of file Local_Tokens.cpp.

References ACE_LIB_TEXT, ACE_TCHAR, ACE_TRACE, ACE_TPQ_Entry::client_id(), and waiter_.

Referenced by ACE_Remote_Token_Proxy::acquire(), ACE_Token_Manager::check_deadlock(), ACE_Remote_Token_Proxy::release(), ACE_Remote_Token_Proxy::renew(), and ACE_Remote_Token_Proxy::tryacquire().

01111 {
01112   ACE_TRACE ("ACE_Token_Proxy::client_id");
01113   // Thread-specific.
01114   const ACE_TPQ_Entry *temp = this->waiter_.operator->();
01115   const ACE_TCHAR *id = temp->client_id ();
01116 
01117   if (id == 0)
01118     return ACE_LIB_TEXT ("ERROR NO CLIENT ID");
01119   else
01120     return id;
01121 }

virtual ACE_Token_Proxy* ACE_Token_Proxy::clone void   )  const [pure virtual]
 

Return a dynamically allocated clone of the derived class.

Implemented in ACE_Null_Token, ACE_Local_Mutex, ACE_Local_RLock, ACE_Local_WLock, ACE_Remote_Mutex, ACE_Remote_RLock, ACE_Remote_WLock, and ACE_Token_Collection.

Referenced by ACE_Token_Collection::insert().

virtual ACE_Tokens* ACE_Token_Proxy::create_token const ACE_TCHAR name  )  [protected, pure virtual]
 

Make the correct type of ACE_Tokens. This is called by the Token Manager.

Implemented in ACE_Null_Token, ACE_Local_Mutex, ACE_Local_RLock, ACE_Local_WLock, ACE_Remote_Mutex, ACE_Remote_RLock, ACE_Remote_WLock, and ACE_Token_Collection.

Referenced by ACE_Token_Manager::get_token().

void ACE_Token_Proxy::dump void   )  const
 

Dump the state of the class.

Reimplemented in ACE_Null_Token, ACE_Local_Mutex, ACE_Local_RLock, ACE_Local_WLock, ACE_Remote_Token_Proxy, ACE_Remote_Mutex, ACE_Remote_RLock, ACE_Remote_WLock, and ACE_Token_Collection.

Definition at line 1088 of file Local_Tokens.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, ACE_TSS_TPQ_Entry::dump(), ACE_Tokens::dump(), ignore_deadlock_, LM_DEBUG, and waiter_.

Referenced by ACE_Token_Collection::dump(), and ACE_Remote_Token_Proxy::dump().

01089 {
01090 #if defined (ACE_HAS_DUMP)
01091   ACE_TRACE ("ACE_Token_Proxy::dump");
01092   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
01093   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("ACE_Token_Proxy::dump:\n")
01094                         ACE_LIB_TEXT (" type = %d\n")
01095                         ACE_LIB_TEXT (" ignore_deadlock_ = %d\n")
01096                         ACE_LIB_TEXT (" debug_ = %d\n"),
01097                         (int) this->type (), ignore_deadlock_, debug_));
01098   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("mutex_, and waiter_\n")));
01099 
01100   if (this->token_ != 0)
01101     this->token_->dump ();
01102 
01103   this->waiter_.dump ();
01104   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_Token_Proxy::dump end.\n")));
01105   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
01106 #endif /* ACE_HAS_DUMP */
01107 }

int ACE_Token_Proxy::handle_options ACE_Synch_Options options,
ACE_TOKEN_CONST::COND_VAR cv
[protected]
 

Handles cond_var waits.

Definition at line 1348 of file Local_Tokens.cpp.

References ACE_DEBUG, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_RETURN, ACE_TRACE, ACE_TOKEN_CONST::COND_VAR, LM_DEBUG, LM_ERROR, ACE_Null_Condition::mutex(), ACE_Null_Mutex::release(), ACE_Synch_Options::time_value(), and ACE_Null_Condition::wait().

Referenced by acquire(), and renew().

01350 {
01351   // Some operation failed with EWOULDBLOCK.
01352   ACE_TRACE ("ACE_Token_Proxy::handle_options");
01353 
01354   if (options[ACE_Synch_Options::USE_REACTOR] == 1)
01355     // Asynchronous.
01356     {
01357       // Save/restore errno.
01358       ACE_Errno_Guard error (errno);
01359       cv.mutex ().release ();
01360       ACE_RETURN (-1);
01361     }
01362   else
01363     // Synchronous.
01364     {
01365       // Block on condition variable.
01366       while (cv.wait ((ACE_Time_Value *) options.time_value ()) == -1)
01367         {
01368           // Note, this should obey whatever thread-specific
01369           // interrupt policy is currently in place...
01370           if (errno == EINTR)
01371             continue;
01372           // We come here if a timeout occurs or some serious
01373           // ACE_Condition object error.
01374           cv.mutex ().release ();
01375           ACE_ERROR_RETURN ((LM_ERROR, ACE_LIB_TEXT ("condition variable wait")
01376                              ACE_LIB_TEXT (" bombed.")), -1);
01377         }
01378 
01379       if (this->debug_)
01380         ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%t) unblocking %s.\n"),
01381                     this->client_id ()));
01382       cv.mutex ().release ();
01383       return 0;       // operation succeeded
01384     }
01385 }

const ACE_TCHAR * ACE_Token_Proxy::name void   )  const [virtual]
 

Return the name of the token. This is important for use within the token servers (local and remote) as well as with token collections. So, all derivations of ACE_Token_Proxy must be able to stringify some name. The name must uniquely identify a token. So, for instance, the token within the reactor should probably be called "Reactor Token."

Reimplemented in ACE_Token_Collection.

Definition at line 1138 of file Local_Tokens.cpp.

References ACE_TRACE, and ACE_Tokens::name().

Referenced by ACE_Remote_Token_Proxy::acquire(), ACE_Token_Invariant_Manager::acquired(), ACE_Token_Collection::insert(), ACE_Token_Collection::is_member(), ACE_Remote_Token_Proxy::release(), ACE_Token_Invariant_Manager::releasing(), ACE_Remote_Token_Proxy::renew(), ACE_Remote_Token_Proxy::token_acquired(), and ACE_Remote_Token_Proxy::tryacquire().

01139 {
01140   ACE_TRACE ("ACE_Token_Proxy::name");
01141   return this->token_->name ();
01142 }

int ACE_Token_Proxy::open const ACE_TCHAR name,
int  ignore_deadlock = 0,
int  debug = 0
[virtual]
 

Open the .

Parameters:
name The string uniquely identifying the token.
ignore_deadlock Can be 1 to disable deadlock notifications.
debug Prints debug messages.

Reimplemented in ACE_Remote_Token_Proxy.

Definition at line 1174 of file Local_Tokens.cpp.

References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TCHAR, ACE_TRACE, ACE_Token_Manager::get_token(), ignore_deadlock_, ACE_Token_Manager::instance(), LM_ERROR, and ACE_OS::sprintf().

Referenced by ACE_Remote_Token_Proxy::open().

01177 {
01178   ACE_TRACE ("ACE_Token_Proxy::open");
01179 
01180   // Store some parameters.
01181   this->ignore_deadlock_ = ignore_deadlock;
01182   this->debug_ = debug;
01183 
01184   // Used in case a name was not specified.
01185   ACE_TCHAR name[BUFSIZ];
01186 
01187   // We must have a name.
01188   if (token_name == 0)
01189     {
01190       ACE_OS::sprintf (name, ACE_LIB_TEXT ("token %lx"),
01191                        reinterpret_cast<long> (this));
01192       token_name = name;
01193     }
01194 
01195   // Get or create the underlying token.  The Token Manager will call
01196   // us back to set token_.
01197   ACE_Token_Manager::instance ()->get_token (this, token_name);
01198 
01199   // Check for failed get or failed new.
01200   if (this->token_ == 0)
01201     {
01202       errno = ENOMEM;
01203       ACE_ERROR_RETURN ((LM_ERROR, ACE_LIB_TEXT ("Can't allocate mutex")), -1);
01204     }
01205 
01206   return 0;
01207 }

const ACE_TCHAR * ACE_Token_Proxy::owner_id void   )  [virtual]
 

The client id of the current token holder.

Reimplemented in ACE_Remote_Token_Proxy.

Definition at line 1131 of file Local_Tokens.cpp.

References ACE_TRACE, and ACE_Tokens::owner_id().

01132 {
01133   ACE_TRACE ("ACE_Token_Proxy::owner_id");
01134   return this->token_->owner_id ();
01135 }

int ACE_Token_Proxy::release ACE_Synch_Options options = ACE_Synch_Options::defaults  )  [virtual]
 

Calls release on the token.

Reimplemented in ACE_Null_Token, ACE_Remote_Token_Proxy, and ACE_Token_Collection.

Definition at line 1388 of file Local_Tokens.cpp.

References ACE_DEBUG, ACE_LIB_TEXT, ACE_RETURN, ACE_TRACE, LM_DEBUG, ACE_Tokens::owner_id(), ACE_Tokens::release(), ACE_Tokens::remove(), and waiter_.

Referenced by ACE_Remote_Token_Proxy::acquire(), ACE_Token_Collection::release(), ACE_Remote_Token_Proxy::release(), and ACE_Remote_Token_Proxy::renew().

01389 {
01390   ACE_TRACE ("ACE_Token_Proxy::release");
01391 
01392   if (this->token_ == 0)
01393     {
01394       errno = ENOENT;
01395       if (debug_)
01396         ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("Must open before releasing.\n")));
01397       ACE_RETURN (-1);
01398     }
01399 
01400   if (this->token_->release (waiter_) != 0)
01401     {
01402       // Release failed.
01403       this->token_->remove (this->waiter_);
01404       if (debug_)
01405         ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%t) %p.\n"), ACE_LIB_TEXT ("release failed")));
01406       return -1;
01407     }
01408   else
01409     {
01410       if (this->debug_)
01411         ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%t) released %s, owner is %s\n"),
01412                     this->name (),
01413                     token_->owner_id ()));
01414 
01415       return 0;
01416     }
01417 }

int ACE_Token_Proxy::remove ACE_Synch_Options options = ACE_Synch_Options::defaults  )  [virtual]
 

Calls remove on the token.

Reimplemented in ACE_Null_Token, and ACE_Remote_Token_Proxy.

Definition at line 1420 of file Local_Tokens.cpp.

References ACE_TRACE.

01421 {
01422   ACE_TRACE ("ACE_Token_Proxy::remove");
01423   return 0;
01424 }

int ACE_Token_Proxy::renew int  requeue_position = -1,
ACE_Synch_Options options = ACE_Synch_Options::defaults
[virtual]
 

Calls renew on the token. Blocks the calling thread if would block.

Reimplemented in ACE_Null_Token, ACE_Remote_Token_Proxy, and ACE_Token_Collection.

Definition at line 1305 of file Local_Tokens.cpp.

References ACE_DEBUG, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TRACE, ACE_Null_Mutex::acquire(), ACE_TPQ_Entry::cond_var_, EWOULDBLOCK, handle_options(), LM_DEBUG, LM_ERROR, ACE_Null_Condition::mutex(), ACE_Tokens::owner_id(), ACE_Null_Mutex::release(), ACE_Tokens::renew(), and waiter_.

Referenced by ACE_Token_Collection::renew(), and ACE_Remote_Token_Proxy::renew().

01307 {
01308   ACE_TRACE ("ACE_Token_Proxy::renew");
01309   if (this->token_ == 0)
01310     {
01311       errno = ENOENT;
01312       ACE_ERROR_RETURN ((LM_ERROR,
01313                          ACE_LIB_TEXT ("Not open.\n")),
01314                         -1);
01315     }
01316 
01317   // Make sure no one calls our token_acquired until we have a chance
01318   // to sleep first!
01319   this->waiter_->cond_var_.mutex ().acquire ();
01320 
01321   if (this->token_->renew (this->waiter_, requeue_position) == -1)
01322     {
01323       // check for error
01324       if (errno != EWOULDBLOCK)
01325         ACE_ERROR_RETURN ((LM_ERROR,
01326                            ACE_LIB_TEXT ("%p renew failed\n"), ACE_LIB_TEXT ("ACE_Token_Proxy")), -1);
01327 
01328       if (this->debug_)
01329         ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%t) renew blocking for %s, owner is %s\n"),
01330                     this->name (),
01331                     token_->owner_id ()));
01332 
01333       // no error, but would block, so block or return
01334       return this->handle_options (options, waiter_->cond_var_);
01335     }
01336   else
01337     // we have the token
01338     {
01339       if (this->debug_)
01340         ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%t) renewed %s\n"),
01341                     this->name ()));
01342       waiter_->cond_var_.mutex ().release ();
01343       return 0;
01344     }
01345 }

void ACE_Token_Proxy::sleep_hook void   )  [virtual]
 

This should really be called . This is called by ACE_Token_xx's when another proxy enters the waiting list and requests that the current token holder be notified.

Definition at line 1427 of file Local_Tokens.cpp.

References ACE_TRACE.

01428 {
01429   ACE_TRACE ("ACE_Token_Proxy::sleep_hook");
01430   // Somebody wants our token!  (Let'em wait...)
01431   return;
01432 }

void ACE_Token_Proxy::token_acquired ACE_TPQ_Entry  )  [virtual]
 

This is called when a queued (waiting) proxy is removed from the waiters list and given the token.

Reimplemented in ACE_Remote_Token_Proxy.

Definition at line 1435 of file Local_Tokens.cpp.

References ACE_TRACE, ACE_Null_Mutex::acquire(), ACE_TPQ_Entry::cond_var_, ACE_Null_Condition::mutex(), ACE_Null_Mutex::release(), and ACE_Null_Condition::signal().

Referenced by ACE_RW_Token::notify_new_owner(), ACE_Mutex_Token::release(), and ACE_Mutex_Token::renew().

01436 {
01437   ACE_TRACE ("ACE_Token_Proxy::token_acquired");
01438   e->cond_var_.mutex ().acquire ();
01439   // We've been taken off the waiters list and given the token!
01440   // This implementation signals the internal condition
01441   // variable. Thus, if asynchronous acquires are used, this must be
01442   // overriden to do something more useful!
01443   e->cond_var_.signal ();
01444   e->cond_var_.mutex ().release ();
01445 
01446   return;
01447 }

int ACE_Token_Proxy::tryacquire void(*  sleep_hook)(void *) = 0  )  [virtual]
 

Calls renew on the token.

Reimplemented in ACE_Null_Token, ACE_Remote_Token_Proxy, and ACE_Token_Collection.

Definition at line 1288 of file Local_Tokens.cpp.

References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TRACE, LM_ERROR, ACE_TPQ_Entry::sleep_hook(), ACE_Tokens::tryacquire(), and waiter_.

Referenced by ACE_Token_Collection::tryacquire(), ACE_Remote_Token_Proxy::tryacquire(), tryacquire_read(), and tryacquire_write().

01289 {
01290   ACE_TRACE ("ACE_Token_Proxy::tryacquire");
01291   if (this->token_ == 0)
01292     {
01293       errno = ENOENT;
01294       ACE_ERROR_RETURN ((LM_ERROR,
01295                          ACE_LIB_TEXT ("Not open.\n")),
01296                         -1);
01297     }
01298 
01299   this->waiter_->sleep_hook (sleep_hook);
01300 
01301   return this->token_->tryacquire (waiter_);
01302 }

int ACE_Token_Proxy::tryacquire_read void(*  sleep_hook)(void *) = 0  )  [virtual]
 

Since the locking mechanism doesn't support read locks then this just calls .

Definition at line 1477 of file Local_Tokens.cpp.

References tryacquire().

01478 {
01479   return this->tryacquire (sleep_hook);
01480 }

int ACE_Token_Proxy::tryacquire_write void(*  sleep_hook)(void *) = 0  )  [virtual]
 

Since the locking mechanism doesn't support write locks then this just calls .

Definition at line 1483 of file Local_Tokens.cpp.

References tryacquire().

01484 {
01485   return this->tryacquire (sleep_hook);
01486 }

int ACE_Token_Proxy::type void   )  const [virtual]
 

This method can be used be Tokens (e.g. Readers/Writer Tokens) to distinguish between Proxy types. For instance a Reader proxy should return a different type value than a Writer proxy. The default implementation returns 0.

Reimplemented in ACE_Local_RLock, ACE_Local_WLock, ACE_Remote_RLock, and ACE_Remote_WLock.

Definition at line 1450 of file Local_Tokens.cpp.

References ACE_TRACE.

Referenced by ACE_Remote_Token_Proxy::acquire(), ACE_RW_Token::acquire(), ACE_Token_Invariant_Manager::acquired(), ACE_RW_Token::is_owner(), ACE_RW_Token::notify_new_owner(), ACE_RW_Token::owners(), ACE_Remote_Token_Proxy::release(), ACE_RW_Token::release(), ACE_Remote_Token_Proxy::renew(), ACE_RW_Token::renew(), ACE_Remote_Token_Proxy::tryacquire(), and ACE_RW_Token::tryacquire().

01451 {
01452   ACE_TRACE ("ACE_Token_Proxy::type");
01453   return 0;
01454 }


Friends And Related Function Documentation

friend class ACE_Token_Invariant_Manager [friend]
 

Definition at line 755 of file Local_Tokens.h.

friend class ACE_Token_Manager [friend]
 

Definition at line 754 of file Local_Tokens.h.


Member Data Documentation

int ACE_Token_Proxy::debug_ [protected]
 

Print a bunch of debug messages.

Reimplemented in ACE_Token_Collection.

Definition at line 885 of file Local_Tokens.h.

int ACE_Token_Proxy::ignore_deadlock_ [protected]
 

If this is set, we ignore deadlock.

Definition at line 882 of file Local_Tokens.h.

Referenced by acquire(), dump(), and open().

ACE_Tokens* ACE_Token_Proxy::token_ [protected]
 

Reference to the actual logical token. Many ACE_Local_Mutex proxies can reference the same ACE_Mutex_Token.

Definition at line 889 of file Local_Tokens.h.

Referenced by ACE_Token_Invariant_Manager::acquired(), ACE_Token_Manager::check_deadlock(), ACE_Token_Manager::get_token(), and ACE_Token_Invariant_Manager::releasing().

ACE_TSS_TPQ_Entry ACE_Token_Proxy::waiter_ [protected]
 

Waiter info used for asynchronous transactions.

Definition at line 896 of file Local_Tokens.h.

Referenced by acquire(), client_id(), dump(), release(), renew(), and tryacquire().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:31:48 2006 for ACE by doxygen 1.3.6