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

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 Methods

 ACE_Token_Proxy (void)
 Construction. More...

virtual ~ACE_Token_Proxy (void)
 Destructor. More...

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)
 Calls acquire on the token. Blocks the calling thread if would block. More...

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. More...

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

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

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

virtual int acquire_read (int notify=0, void(*sleep_hook)(void *)=0, ACE_Synch_Options &options=ACE_Synch_Options::defaults)
 Since the locking mechanism doesn't support read locks then this just calls <acquire>. More...

virtual int acquire_write (int notify=0, void(*sleep_hook)(void *)=0, ACE_Synch_Options &options=ACE_Synch_Options::defaults)
 Since the locking mechanism doesn't support write locks then this just calls <acquire>. More...

virtual int tryacquire_read (void(*sleep_hook)(void *)=0)
 Since the locking mechanism doesn't support read locks then this just calls <tryacquire>. More...

virtual int tryacquire_write (void(*sleep_hook)(void *)=0)
 Since the locking mechanism doesn't support write locks then this just calls <tryacquire>. More...

virtual const ACE_TCHARclient_id (void) const
 Get the client id of the proxy. This is implemented as thread-specific data. More...

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 *)
 This is called when a queued (waiting) proxy is removed from the waiters list and given the token. More...

virtual const ACE_TCHARowner_id (void)
 The client id of the current token holder. More...

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

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

virtual int type (void) const

Protected Methods

 ACE_Token_Proxy (const ACE_Token_Proxy &)
 Duplication. More...

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

virtual ACE_Tokenscreate_token (const ACE_TCHAR *name)=0
 Make the correct type of ACE_Tokens. This is called by the Token Manager. More...


Protected Attributes

int ignore_deadlock_
 If this is set, we ignore deadlock. More...

int debug_
 Print a bunch of debug messages. More...

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

ACE_TSS_TPQ_Entry waiter_
 Waiter info used for asynchronous transactions. More...


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 746 of file Local_Tokens.h.


Constructor & Destructor Documentation

ACE_Token_Proxy::ACE_Token_Proxy void   
 

Construction.

Definition at line 1095 of file Local_Tokens.cpp.

References ACE_TRACE.

01096 : token_ (0),
01097   waiter_ (this, 0)
01098 {
01099   ACE_TRACE ("ACE_Token_Proxy::ACE_Token_Proxy");
01100 }

ACE_Token_Proxy::~ACE_Token_Proxy void    [virtual]
 

Destructor.

Definition at line 1114 of file Local_Tokens.cpp.

References ACE_TRACE, ACE_Token_Manager::instance, ACE_Token_Manager::release_token, and token_.

01115 {
01116   ACE_TRACE ("ACE_Token_Proxy::~ACE_Token_Proxy");
01117 
01118   if (token_ != 0)
01119     // notify token manager that we are done with it so it can
01120     // free it if necessary
01121     ACE_Token_Manager::instance ()->release_token (token_);
01122 }

ACE_Token_Proxy::ACE_Token_Proxy const ACE_Token_Proxy &    [protected]
 

Duplication.

Definition at line 1106 of file Local_Tokens.cpp.

References ACE_TRACE.

01107   : token_ (0),
01108     waiter_ (this, 0)
01109 {
01110   ACE_TRACE ("ACE_Token_Proxy::ACE_Token_Proxy");
01111 }


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.

Definition at line 1161 of file Local_Tokens.cpp.

References ACE_DEBUG, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_RETURN, ACE_TRACE, ACE_Tokens::acquire, ACE_TPQ_Entry::cond_var_, debug_, EDEADLK, EWOULDBLOCK, handle_options, ignore_deadlock_, LM_DEBUG, LM_ERROR, ACE_Tokens::no_of_waiters, ACE_Tokens::owner_id, sleep_hook, ACE_TPQ_Entry::sleep_hook, token_, and waiter_.

Referenced by ACE_Token_Collection::acquire, and ACE_Remote_Token_Proxy::acquire.

01164 {
01165   ACE_TRACE ("ACE_Token_Proxy::acquire");
01166   if (this->token_ == 0)
01167     {
01168       errno = ENOENT;
01169       ACE_ERROR_RETURN ((LM_ERROR, ACE_LIB_TEXT ("Not open.\n")), -1);
01170     }
01171 
01172   // Make sure no one calls our token_acquired until we have a chance
01173   // to sleep first!  If after we call an EWOULDBLOCK
01174   // mutex_->acquire() below, but before we enter handle_options to
01175   // wait on the cond_var, a thread tries to give take us off the
01176   // waiter queue and signal us, IT WILL FIRST HAVE TO ACQUIRE THIS
01177   // cond_var.mutex ().  _This_ is why we acquire it.
01178   this->waiter_->cond_var_.mutex ().acquire ();
01179 
01180   this->waiter_->sleep_hook (sleep_hook);
01181 
01182   if (this->token_->acquire (this->waiter_, this->ignore_deadlock_, notify) == -1)
01183     // acquire failed
01184     {
01185       switch (errno)
01186         {
01187         case EDEADLK :
01188           if (!ignore_deadlock_)
01189             {
01190               waiter_->cond_var_.mutex ().release ();
01191               errno = EDEADLK;
01192               ACE_RETURN (-1);
01193             }
01194           // Else, fallthrough and block!
01195 
01196         case EWOULDBLOCK :
01197           if (this->debug_)
01198             ACE_DEBUG ((LM_DEBUG,
01199                         ACE_LIB_TEXT ("(%t) waiting for %s, owner is %s, ")
01200                         ACE_LIB_TEXT ("total waiters == %d\n"),
01201                         this->name (),
01202                         this->token_->owner_id (),
01203                         token_->no_of_waiters ()));
01204 
01205           // no error, but would block, if error, return error (-1),
01206           // otherwise, return whether we called the holder or not.
01207           int return_value;
01208           if (this->handle_options (options,
01209                                     waiter_->cond_var_) == -1)
01210             return_value = -1;
01211           else
01212             return_value = notify == 1;
01213 
01214           errno = EWOULDBLOCK;
01215           ACE_RETURN (return_value);
01216 
01217         default :
01218           waiter_->cond_var_.mutex ().release ();
01219           ACE_ERROR_RETURN ((LM_ERROR,
01220                              ACE_LIB_TEXT ("%p\n"),
01221                              ACE_LIB_TEXT ("Token Proxy acquire.")),
01222                             -1);
01223         }
01224     }
01225   else
01226     // we have the token
01227     {
01228       if (debug_)
01229         ACE_DEBUG ((LM_DEBUG,
01230                     ACE_LIB_TEXT ("(%t) acquired %s\n"),
01231                     this->name ()));
01232       waiter_->cond_var_.mutex ().release ();
01233     }
01234 
01235   return 0;
01236 }

virtual 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 <acquire>.

virtual 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 <acquire>.

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 1075 of file Local_Tokens.cpp.

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

01076 {
01077   ACE_TRACE ("ACE_Token_Proxy::client_id");
01078   this->waiter_->client_id (client_id);
01079 }

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 1058 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, client_id, ACE_Remote_Token_Proxy::release, ACE_Remote_Token_Proxy::renew, and ACE_Remote_Token_Proxy::tryacquire.

01059 {
01060   ACE_TRACE ("ACE_Token_Proxy::client_id");
01061   // Thread-specific.
01062   ACE_Token_Proxy *nc_this =
01063     ACE_const_cast (ACE_Token_Proxy *, this);
01064   const ACE_TPQ_Entry *temp =
01065     nc_this->waiter_.operator->();
01066   const ACE_TCHAR *id = temp->client_id ();
01067 
01068   if (id == 0)
01069     return ACE_LIB_TEXT ("ERROR NO CLIENT ID");
01070   else
01071     return id;
01072 }

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.

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.

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.

Definition at line 1038 of file Local_Tokens.cpp.

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

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

01039 {
01040   ACE_TRACE ("ACE_Token_Proxy::dump");
01041   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
01042   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("ACE_Token_Proxy::dump:\n")
01043                         ACE_LIB_TEXT (" type = %d\n")
01044                         ACE_LIB_TEXT (" ignore_deadlock_ = %d\n")
01045                         ACE_LIB_TEXT (" debug_ = %d\n"),
01046                         (int) this->type (), ignore_deadlock_, debug_));
01047   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("mutex_, and waiter_\n")));
01048 
01049   if (this->token_ != 0)
01050     this->token_->dump ();
01051 
01052   this->waiter_.dump ();
01053   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_Token_Proxy::dump end.\n")));
01054   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
01055 }

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

Handles cond_var waits.

Definition at line 1299 of file Local_Tokens.cpp.

References ACE_DEBUG, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_RETURN, ACE_TRACE, ACE_TOKEN_CONST::COND_VAR, debug_, LM_DEBUG, LM_ERROR, ACE_Synch_Options::time_value, and ACE_Synch_Options::USE_REACTOR.

Referenced by acquire, and renew.

01301 {
01302   // Some operation failed with EWOULDBLOCK.
01303   ACE_TRACE ("ACE_Token_Proxy::handle_options");
01304 
01305   if (options[ACE_Synch_Options::USE_REACTOR] == 1)
01306     // Asynchronous.
01307     {
01308       // Save/restore errno.
01309       ACE_Errno_Guard error (errno);
01310       cv.mutex ().release ();
01311       ACE_RETURN (-1);
01312     }
01313   else
01314     // Synchronous.
01315     {
01316       // Block on condition variable.
01317       while (cv.wait ((ACE_Time_Value *) options.time_value ()) == -1)
01318         {
01319           // Note, this should obey whatever thread-specific
01320           // interrupt policy is currently in place...
01321           if (errno == EINTR)
01322             continue;
01323           // We come here if a timeout occurs or some serious
01324           // ACE_Condition object error.
01325           cv.mutex ().release ();
01326           ACE_ERROR_RETURN ((LM_ERROR, ACE_LIB_TEXT ("condition variable wait")
01327                              ACE_LIB_TEXT (" bombed.")), -1);
01328         }
01329 
01330       if (this->debug_)
01331         ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%t) unblocking.\n"),
01332                     this->client_id ()));
01333       cv.mutex ().release ();
01334       return 0;       // operation succeeded
01335     }
01336 }

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 1089 of file Local_Tokens.cpp.

References ACE_TRACE, ACE_Tokens::name, and token_.

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

01090 {
01091   ACE_TRACE ("ACE_Token_Proxy::name");
01092   return this->token_->name ();
01093 }

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

Open the <ACE_Token>.

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 1125 of file Local_Tokens.cpp.

References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TCHAR, ACE_TRACE, debug_, ACE_Token_Manager::get_token, ignore_deadlock_, ACE_Token_Manager::instance, LM_ERROR, name, ACE_OS::sprintf, and token_.

Referenced by ACE_Remote_Token_Proxy::open.

01128 {
01129   ACE_TRACE ("ACE_Token_Proxy::open");
01130 
01131   // Store some parameters.
01132   this->ignore_deadlock_ = ignore_deadlock;
01133   this->debug_ = debug;
01134 
01135   // Used in case a name was not specified.
01136   ACE_TCHAR name[BUFSIZ];
01137 
01138   // We must have a name.
01139   if (token_name == 0)
01140     {
01141       ACE_OS::sprintf (name, ACE_LIB_TEXT ("token %lx"),
01142                        ACE_reinterpret_cast (long, this));
01143       token_name = name;
01144     }
01145 
01146   // Get or create the underlying token.  The Token Manager will call
01147   // us back to set token_.
01148   ACE_Token_Manager::instance ()->get_token (this, token_name);
01149 
01150   // Check for failed get or failed new.
01151   if (this->token_ == 0)
01152     {
01153       errno = ENOMEM;
01154       ACE_ERROR_RETURN ((LM_ERROR, ACE_LIB_TEXT ("Can't allocate mutex")), -1);
01155     }
01156 
01157   return 0;
01158 }

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 1082 of file Local_Tokens.cpp.

References ACE_TRACE, ACE_Tokens::owner_id, and token_.

01083 {
01084   ACE_TRACE ("ACE_Token_Proxy::owner_id");
01085   return this->token_->owner_id ();
01086 }

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

Calls release on the token.

Reimplemented in ACE_Null_Token.

Definition at line 1339 of file Local_Tokens.cpp.

References ACE_DEBUG, ACE_LIB_TEXT, ACE_RETURN, ACE_TRACE, debug_, LM_DEBUG, ACE_Tokens::owner_id, ACE_Tokens::release, ACE_Tokens::remove, token_, and waiter_.

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

01340 {
01341   ACE_TRACE ("ACE_Token_Proxy::release");
01342 
01343   if (this->token_ == 0)
01344     {
01345       errno = ENOENT;
01346       if (debug_)
01347         ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("Must open before releasing.\n")));
01348       ACE_RETURN (-1);
01349     }
01350 
01351   if (this->token_->release (waiter_) != 0)
01352     {
01353       // Release failed.
01354       this->token_->remove (this->waiter_);
01355       if (debug_)
01356         ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%t) %p.\n"), ACE_LIB_TEXT ("release failed")));
01357       return -1;
01358     }
01359   else
01360     {
01361       if (this->debug_)
01362         ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%t) released %s, owner is %s\n"),
01363                     this->name (),
01364                     token_->owner_id ()));
01365 
01366       return 0;
01367     }
01368 }

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

Calls remove on the token.

Reimplemented in ACE_Null_Token.

Definition at line 1371 of file Local_Tokens.cpp.

References ACE_TRACE.

01372 {
01373   ACE_TRACE ("ACE_Token_Proxy::remove");
01374   return 0;
01375 }

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.

Definition at line 1256 of file Local_Tokens.cpp.

References ACE_DEBUG, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TRACE, ACE_TPQ_Entry::cond_var_, debug_, EWOULDBLOCK, handle_options, LM_DEBUG, LM_ERROR, ACE_Tokens::owner_id, ACE_Tokens::renew, token_, and waiter_.

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

01258 {
01259   ACE_TRACE ("ACE_Token_Proxy::renew");
01260   if (this->token_ == 0)
01261     {
01262       errno = ENOENT;
01263       ACE_ERROR_RETURN ((LM_ERROR,
01264                          ACE_LIB_TEXT ("Not open.\n")),
01265                         -1);
01266     }
01267 
01268   // Make sure no one calls our token_acquired until we have a chance
01269   // to sleep first!
01270   this->waiter_->cond_var_.mutex ().acquire ();
01271 
01272   if (this->token_->renew (this->waiter_, requeue_position) == -1)
01273     {
01274       // check for error
01275       if (errno != EWOULDBLOCK)
01276         ACE_ERROR_RETURN ((LM_ERROR,
01277                            ACE_LIB_TEXT ("%p renew failed\n"), ACE_LIB_TEXT ("ACE_Token_Proxy")), -1);
01278 
01279       if (this->debug_)
01280         ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%t) renew blocking for %s, owner is %s\n"),
01281                     this->name (),
01282                     token_->owner_id ()));
01283 
01284       // no error, but would block, so block or return
01285       return this->handle_options (options, waiter_->cond_var_);
01286     }
01287   else
01288     // we have the token
01289     {
01290       if (this->debug_)
01291         ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("(%t) renewed %s\n"),
01292                     this->name ()));
01293       waiter_->cond_var_.mutex ().release ();
01294       return 0;
01295     }
01296 }

void ACE_Token_Proxy::sleep_hook void    [virtual]
 

This should really be called <someone_waiting>. 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 1378 of file Local_Tokens.cpp.

References ACE_TRACE.

Referenced by ACE_Token_Collection::acquire, ACE_Remote_Token_Proxy::acquire, acquire, ACE_Token_Collection::tryacquire, ACE_Remote_Token_Proxy::tryacquire, and tryacquire.

01379 {
01380   ACE_TRACE ("ACE_Token_Proxy::sleep_hook");
01381   // Somebody wants our token!  (Let'em wait...)
01382   return;
01383 }

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 1386 of file Local_Tokens.cpp.

References ACE_TRACE, and ACE_TPQ_Entry::cond_var_.

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

01387 {
01388   ACE_TRACE ("ACE_Token_Proxy::token_acquired");
01389   e->cond_var_.mutex ().acquire ();
01390   // We've been taken off the waiters list and given the token!
01391   // This implementation signals the internal condition
01392   // variable. Thus, if asynchronous acquires are used, this must be
01393   // overriden to do something more useful!
01394   e->cond_var_.signal ();
01395   e->cond_var_.mutex ().release ();
01396 
01397   return;
01398 }

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

Calls renew on the token.

Reimplemented in ACE_Null_Token.

Definition at line 1239 of file Local_Tokens.cpp.

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

Referenced by ACE_Token_Collection::tryacquire, and ACE_Remote_Token_Proxy::tryacquire.

01240 {
01241   ACE_TRACE ("ACE_Token_Proxy::tryacquire");
01242   if (this->token_ == 0)
01243     {
01244       errno = ENOENT;
01245       ACE_ERROR_RETURN ((LM_ERROR,
01246                          ACE_LIB_TEXT ("Not open.\n")),
01247                         -1);
01248     }
01249 
01250   this->waiter_->sleep_hook (sleep_hook);
01251 
01252   return this->token_->tryacquire (waiter_);
01253 }

virtual 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 <tryacquire>.

virtual 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 <tryacquire>.

virtual 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.

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.


Friends And Related Function Documentation

friend class ACE_Token_Invariant_Manager [friend]
 

Definition at line 750 of file Local_Tokens.h.

friend class ACE_Token_Manager [friend]
 

Definition at line 749 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 880 of file Local_Tokens.h.

Referenced by acquire, dump, handle_options, open, release, and renew.

int ACE_Token_Proxy::ignore_deadlock_ [protected]
 

If this is set, we ignore deadlock.

Definition at line 877 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 884 of file Local_Tokens.h.

Referenced by ACE_Remote_Token_Proxy::acquire, acquire, ACE_Token_Invariant_Manager::acquired, ACE_Token_Manager::check_deadlock, dump, ACE_Token_Manager::get_token, ACE_Remote_Token_Proxy::initiate_connection, name, open, owner_id, ACE_Remote_Token_Proxy::release, release, ACE_Token_Invariant_Manager::releasing, ACE_Remote_Token_Proxy::renew, renew, ACE_Remote_Token_Proxy::tryacquire, tryacquire, and ~ACE_Token_Proxy.

ACE_TSS_TPQ_Entry ACE_Token_Proxy::waiter_ [protected]
 

Waiter info used for asynchronous transactions.

Definition at line 891 of file Local_Tokens.h.

Referenced by ACE_Remote_Token_Proxy::acquire, acquire, client_id, dump, release, ACE_Remote_Token_Proxy::renew, renew, and tryacquire.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:58:30 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002