ACE  6.1.0
Public Member Functions | Protected Member Functions | Protected Attributes | Friends
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.


Constructor & Destructor Documentation

ACE_Token_Proxy::ACE_Token_Proxy ( void  )

Construction.

ACE_Token_Proxy::~ACE_Token_Proxy ( void  ) [virtual]

Destructor.

ACE_Token_Proxy::ACE_Token_Proxy ( const ACE_Token_Proxy ) [protected]

Duplication.


Member Function Documentation

int ACE_Token_Proxy::acquire ( int  notify = 0,
void(*)(void *)  sleep_hook = 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_Token_Collection, and ACE_Remote_Token_Proxy.

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

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

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

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

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.

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.

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

Return a dynamically allocated clone of the derived class.

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

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_Local_WLock, ACE_Local_RLock, ACE_Local_Mutex, ACE_Null_Token, ACE_Remote_WLock, ACE_Remote_RLock, ACE_Token_Collection, and ACE_Remote_Mutex.

void ACE_Token_Proxy::dump ( void  ) const
int ACE_Token_Proxy::handle_options ( ACE_Synch_Options options,
ACE_TOKEN_CONST::COND_VAR cv 
) [protected]

Handles cond_var waits.

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.

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

Open the <ACE_Token>.

Parameters:
nameThe string uniquely identifying the token.
ignore_deadlockCan be 1 to disable deadlock notifications.
debugPrints debug messages.

Reimplemented in ACE_Remote_Token_Proxy.

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

The client id of the current token holder.

Reimplemented in ACE_Remote_Token_Proxy.

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_Token_Collection, and ACE_Remote_Token_Proxy.

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.

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_Token_Collection, and ACE_Remote_Token_Proxy.

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.

void ACE_Token_Proxy::token_acquired ( ACE_TPQ_Entry e) [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.

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

Calls renew on the token.

Reimplemented in ACE_Null_Token, ACE_Token_Collection, and ACE_Remote_Token_Proxy.

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

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

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

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

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_WLock, ACE_Local_RLock, ACE_Remote_WLock, and ACE_Remote_RLock.


Friends And Related Function Documentation

friend class ACE_Token_Invariant_Manager [friend]
friend class ACE_Token_Manager [friend]

Member Data Documentation

int ACE_Token_Proxy::debug_ [protected]

Print a bunch of debug messages.

Reimplemented in ACE_Token_Collection.

If this is set, we ignore deadlock.

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

Waiter info used for asynchronous transactions.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines