ACE_Tokens Class Reference

Abstract representation of ACE tokens. More...

#include <Local_Tokens.h>

Inheritance diagram for ACE_Tokens:

Inheritance graph
[legend]
Collaboration diagram for ACE_Tokens:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Unbounded_Stack<
ACE_TPQ_Entry * > 
OWNER_STACK
 Stack of owners.

enum  TOKEN_TYPES { MUTEX, RWLOCK }

Public Member Functions

 ACE_Tokens (void)
 Null constructor.

virtual ~ACE_Tokens (void)
 Destructor.

virtual int acquire (ACE_TPQ_Entry *caller, int ignore_deadlock, int notify)=0
 No implementation.

virtual int tryacquire (ACE_TPQ_Entry *caller)=0
 No implementation.

virtual int renew (ACE_TPQ_Entry *caller, int requeue_position)=0
 No implementation.

virtual int release (ACE_TPQ_Entry *caller)=0
 No implementation.

void make_owner (ACE_TPQ_Entry *caller)
void remove (ACE_TPQ_Entry *caller)
 Remove the caller from the waiter list.

virtual int owners (OWNER_STACK &o, const ACE_TCHAR *id)=0
virtual int is_waiting_for (const ACE_TCHAR *id)=0
 Returns 1 if is waiting for this token. 0 otherwise.

virtual int is_owner (const ACE_TCHAR *id)=0
 Returns 1 if is an owner of this token. 0 otherwise.

virtual ACE_Token_Proxy_Queuewaiters (void)
 Return the queue of waiters.

virtual int no_of_waiters (void)
const ACE_TCHARowner_id (void)
 The current owner.

const ACE_TCHARname (void)
 Token name.

void inc_reference (void)
int dec_reference (void)
void dump (void) const
 Dump the state of the class.

virtual int type (void) const=0
void visit (int v)
 Mark or unmark the token as visited.

int visited (void)
 Check if the token has been visited.

ACE_TPQ_Entryowner (void)
 All the data of the current owner.


Protected Attributes

int visited_
 For the deadlock detection algorithm.

int reference_count_
 Reference count.

ACE_Token_Proxy_Queue waiters_
 List of client's owning and waiting the token.

ACE_TCHAR token_name_ [ACE_MAXTOKENNAMELEN]
 Name of token.


Detailed Description

Abstract representation of ACE tokens.

Not a public interface. Currently, I don't see a reason for providing an abstract interface at this level of the library. As of yet, no one uses ACE_Tokens derivatives through this abstract interface except for ACE_Token_Manager. It only uses the statistical methods which are shared by all Tokens. For that reason, it still makes since to have a common base class. However, acquire, renew, and release do not need to have matching interfaces throughout all Tokens. To add a new type of token (e.g. semaphore), this class must be subtyped to define the new semantics. See ACE_Token_Manager for details.

Definition at line 371 of file Local_Tokens.h.


Member Typedef Documentation

typedef ACE_Unbounded_Stack<ACE_TPQ_Entry *> ACE_Tokens::OWNER_STACK
 

Stack of owners.

Definition at line 406 of file Local_Tokens.h.

Referenced by ACE_Token_Manager::check_deadlock().


Member Enumeration Documentation

enum ACE_Tokens::TOKEN_TYPES
 

These are the Token types supported by the library at ship time. There is no restriction on the number of Token types added by "3rd parties." These are only necessary for the Token Server.

Enumeration values:
MUTEX 
RWLOCK 

Definition at line 444 of file Local_Tokens.h.

00444 { MUTEX, RWLOCK };


Constructor & Destructor Documentation

ACE_Tokens::ACE_Tokens void   ) 
 

Null constructor.

Definition at line 38 of file Local_Tokens.cpp.

References ACE_TRACE.

00039   : visited_ (0),
00040     reference_count_ (0)
00041 {
00042   ACE_TRACE ("ACE_Tokens::ACE_Tokens");
00043 }

ACE_Tokens::~ACE_Tokens void   )  [virtual]
 

Destructor.

Definition at line 45 of file Local_Tokens.cpp.

00046 {
00047 }


Member Function Documentation

virtual int ACE_Tokens::acquire ACE_TPQ_Entry caller,
int  ignore_deadlock,
int  notify
[pure virtual]
 

No implementation.

Implemented in ACE_Mutex_Token, and ACE_RW_Token.

Referenced by ACE_Token_Proxy::acquire().

int ACE_Tokens::dec_reference void   ) 
 

Referenced by ACE_Token_Manager::release_token().

ACE_BEGIN_VERSIONED_NAMESPACE_DECL void ACE_Tokens::dump void   )  const
 

Dump the state of the class.

Reimplemented in ACE_Mutex_Token, and ACE_RW_Token.

Definition at line 23 of file Local_Tokens.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, ACE_Token_Proxy_Queue::dump(), LM_DEBUG, token_name_, and waiters_.

Referenced by ACE_Token_Proxy::dump(), ACE_RW_Token::dump(), and ACE_Mutex_Token::dump().

00024 {
00025 #if defined (ACE_HAS_DUMP)
00026   ACE_TRACE ("ACE_Tokens::dump");
00027   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00028   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("ACE_Tokens::dump:\n")
00029                         ACE_LIB_TEXT (" reference_cont_ = %d\n")
00030                         ACE_LIB_TEXT (" token_name_ = %s\n"),
00031                         reference_count_, token_name_));
00032   ACE_DEBUG ((LM_DEBUG,  ACE_LIB_TEXT ("waiters_\n")));
00033   this->waiters_.dump ();
00034   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00035 #endif /* ACE_HAS_DUMP */
00036 }

void ACE_Tokens::inc_reference void   ) 
 

Referenced by ACE_Token_Manager::get_token().

virtual int ACE_Tokens::is_owner const ACE_TCHAR id  )  [pure virtual]
 

Returns 1 if is an owner of this token. 0 otherwise.

Implemented in ACE_Mutex_Token, and ACE_RW_Token.

virtual int ACE_Tokens::is_waiting_for const ACE_TCHAR id  )  [pure virtual]
 

Returns 1 if is waiting for this token. 0 otherwise.

Implemented in ACE_Mutex_Token, and ACE_RW_Token.

void ACE_Tokens::make_owner ACE_TPQ_Entry caller  ) 
 

Move the caller to the front of the waiter list. This is for use with remote mutexes and shadow mutexes.

Definition at line 50 of file Local_Tokens.cpp.

References ACE_Token_Proxy_Queue::enqueue(), ACE_Token_Proxy_Queue::remove(), and waiters_.

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

00051 {
00052   this->waiters_.remove (caller);
00053   this->waiters_.enqueue (caller, 0);
00054 }

const ACE_TCHAR* ACE_Tokens::name void   ) 
 

Token name.

Referenced by ACE_Token_Manager::check_deadlock(), ACE_Local_WLock::clone(), ACE_Local_RLock::clone(), ACE_Local_Mutex::clone(), ACE_Token_Proxy::name(), and ACE_Token_Manager::release_token().

int ACE_Tokens::no_of_waiters void   )  [virtual]
 

Return the number of proxies that are currently waiting to get the token.

Definition at line 64 of file Local_Tokens.cpp.

References ACE_TRACE, ACE_Token_Proxy_Queue::size(), and waiters_.

Referenced by ACE_Token_Proxy::acquire().

00065 {
00066   ACE_TRACE ("ACE_Tokens::no_of_waiters");
00067   return this->waiters_.size ();
00068 }

ACE_TPQ_Entry* ACE_Tokens::owner void   ) 
 

All the data of the current owner.

Referenced by ACE_RW_Token::acquire(), ACE_Mutex_Token::acquire(), ACE_RW_Token::is_owner(), ACE_Mutex_Token::is_owner(), ACE_RW_Token::is_waiting_for(), ACE_Mutex_Token::is_waiting_for(), ACE_RW_Token::notify_new_owner(), ACE_RW_Token::owners(), ACE_Mutex_Token::owners(), ACE_RW_Token::release(), ACE_Mutex_Token::release(), ACE_Mutex_Token::renew(), ACE_RW_Token::tryacquire(), and ACE_Mutex_Token::tryacquire().

const ACE_TCHAR* ACE_Tokens::owner_id void   ) 
 

The current owner.

Referenced by ACE_Token_Proxy::acquire(), ACE_Token_Proxy::owner_id(), ACE_Token_Proxy::release(), and ACE_Token_Proxy::renew().

virtual int ACE_Tokens::owners OWNER_STACK o,
const ACE_TCHAR id
[pure virtual]
 

Returns a stack of the current owners. Returns -1 on error, 0 on success. If is non-zero, returns 1 if id is an owner.

Implemented in ACE_Mutex_Token, and ACE_RW_Token.

Referenced by ACE_Token_Manager::check_deadlock().

virtual int ACE_Tokens::release ACE_TPQ_Entry caller  )  [pure virtual]
 

No implementation.

Implemented in ACE_Mutex_Token, and ACE_RW_Token.

Referenced by ACE_Token_Proxy::release().

void ACE_Tokens::remove ACE_TPQ_Entry caller  ) 
 

Remove the caller from the waiter list.

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

virtual int ACE_Tokens::renew ACE_TPQ_Entry caller,
int  requeue_position
[pure virtual]
 

No implementation.

Implemented in ACE_Mutex_Token, and ACE_RW_Token.

Referenced by ACE_Token_Proxy::renew().

virtual int ACE_Tokens::tryacquire ACE_TPQ_Entry caller  )  [pure virtual]
 

No implementation.

Implemented in ACE_Mutex_Token, and ACE_RW_Token.

Referenced by ACE_Token_Proxy::tryacquire().

virtual int ACE_Tokens::type void   )  const [pure virtual]
 

Provides a manual RTTI mechanism. This method is used only by ACE_Token_Request so that the type of a token can be sent to a remote Token Server.

Implemented in ACE_Mutex_Token, and ACE_RW_Token.

Referenced by ACE_Remote_Token_Proxy::acquire(), ACE_Token_Invariant_Manager::acquired(), ACE_Remote_Token_Proxy::release(), ACE_Token_Manager::release_token(), ACE_Token_Invariant_Manager::releasing(), ACE_Remote_Token_Proxy::renew(), and ACE_Remote_Token_Proxy::tryacquire().

void ACE_Tokens::visit int  v  ) 
 

Mark or unmark the token as visited.

Referenced by ACE_Token_Manager::check_deadlock().

int ACE_Tokens::visited void   ) 
 

Check if the token has been visited.

Referenced by ACE_Token_Manager::check_deadlock().

ACE_Token_Proxy_Queue * ACE_Tokens::waiters void   )  [virtual]
 

Return the queue of waiters.

Definition at line 57 of file Local_Tokens.cpp.

References ACE_TRACE, and waiters_.

00058 {
00059   ACE_TRACE ("ACE_Tokens::waiters");
00060   return &this->waiters_;
00061 }


Member Data Documentation

int ACE_Tokens::reference_count_ [protected]
 

Reference count.

Definition at line 471 of file Local_Tokens.h.

ACE_TCHAR ACE_Tokens::token_name_[ACE_MAXTOKENNAMELEN] [protected]
 

Name of token.

Definition at line 477 of file Local_Tokens.h.

Referenced by dump().

int ACE_Tokens::visited_ [protected]
 

For the deadlock detection algorithm.

Definition at line 468 of file Local_Tokens.h.

ACE_Token_Proxy_Queue ACE_Tokens::waiters_ [protected]
 

List of client's owning and waiting the token.

Definition at line 474 of file Local_Tokens.h.

Referenced by dump(), make_owner(), no_of_waiters(), and waiters().


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