ACE  6.3.3
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ACE_RW_Token Class Reference

Class that acquires, renews, and releases a process-local synchronization token. More...

#include <Local_Tokens.h>

Inheritance diagram for ACE_RW_Token:
Inheritance graph
[legend]
Collaboration diagram for ACE_RW_Token:
Collaboration graph
[legend]

Public Types

enum  PROXY_TYPE { READER, WRITER }
 These are the types that proxies can be. More...
 
- Public Types inherited from ACE_Tokens
enum  TOKEN_TYPES { MUTEX, RWLOCK }
 
typedef ACE_Unbounded_Stack< ACE_TPQ_Entry * > OWNER_STACK
 Stack of owners. More...
 

Public Member Functions

 ACE_RW_Token (const ACE_TCHAR *name)
 Constructor. More...
 
virtual ~ACE_RW_Token (void)
 Destructor. More...
 
virtual int acquire (ACE_TPQ_Entry *caller, int ignore_deadlock, int notify)
 
virtual int tryacquire (ACE_TPQ_Entry *caller)
 Same as acquire except fails on would block. More...
 
virtual int renew (ACE_TPQ_Entry *caller, int requeue_position)
 
virtual int release (ACE_TPQ_Entry *caller)
 
void dump (void) const
 Dump the state of the class. More...
 
virtual int type (void) const
 Returns READER or WRITER. More...
 
virtual int owners (OWNER_STACK &o, const ACE_TCHAR *id)
 
virtual int is_waiting_for (const ACE_TCHAR *id)
 Returns 1 if id is waiting for this token. 0 otherwise. More...
 
virtual int is_owner (const ACE_TCHAR *id)
 Returns 1 if id is an owner of this token. 0 otherwise. More...
 
- Public Member Functions inherited from ACE_Tokens
 ACE_Tokens (void)
 Null constructor. More...
 
virtual ~ACE_Tokens (void)
 Destructor. More...
 
void make_owner (ACE_TPQ_Entry *caller)
 
void remove (ACE_TPQ_Entry *caller)
 Remove the caller from the waiter list. More...
 
virtual ACE_Token_Proxy_Queuewaiters (void)
 Return the queue of waiters. More...
 
virtual int no_of_waiters (void)
 
const ACE_TCHARowner_id (void)
 The current owner. More...
 
const ACE_TCHARname (void)
 Token name. More...
 
void inc_reference (void)
 
int dec_reference (void)
 
void dump (void) const
 Dump the state of the class. More...
 
void visit (int v)
 Mark or unmark the token as visited. More...
 
int visited (void)
 Check if the token has been visited. More...
 
ACE_TPQ_Entryowner (void)
 All the data of the current owner. More...
 

Protected Member Functions

void notify_new_owner (ACE_TPQ_Entry *caller)
 Sets the new owner. More...
 

Protected Attributes

int num_writers_
 The number of waiting writers. More...
 
ACE_TOKEN_CONST::MUTEX lock_
 ACE_Mutex_Token used to lock internal data structures. More...
 
- Protected Attributes inherited from ACE_Tokens
int visited_
 For the deadlock detection algorithm. More...
 
int reference_count_
 Reference count. More...
 
ACE_Token_Proxy_Queue waiters_
 List of client's owning and waiting the token. More...
 
ACE_TCHAR token_name_ [ACE_MAXTOKENNAMELEN]
 Name of token. More...
 

Detailed Description

Class that acquires, renews, and releases a process-local synchronization token.

Not a public interface. This class is a more general-purpose synchronization mechanism than SunOS 5.x mutexes. For example, it implements "recursive mutex" semantics, where a thread that owns the token can reacquire it without deadlocking. In addition, threads that are blocked awaiting the token are serviced in strict FIFO order as other threads release the token (SunOS 5.x mutexes don't strictly enforce an acquisition order).

Member Enumeration Documentation

These are the types that proxies can be.

Enumerator
READER 
WRITER 

Constructor & Destructor Documentation

ACE_RW_Token::ACE_RW_Token ( const ACE_TCHAR name)
explicit

Constructor.

ACE_RW_Token::~ACE_RW_Token ( void  )
virtual

Destructor.

Member Function Documentation

int ACE_RW_Token::acquire ( ACE_TPQ_Entry caller,
int  ignore_deadlock,
int  notify 
)
virtual

Returns 0 on success, -1 on failure with <ACE_Log_Msg::errnum> as the reason. If errnum == EWOULDBLOCK, and notify == 1, <ACE_Token_Proxy::sleep_hook> has been called on the current owner of the token. If ignore_deadlock is passed as 1 and errnum == EDEADLK, then deadlock was detected via ACE_Token_Manager.

Implements ACE_Tokens.

void ACE_RW_Token::dump ( void  ) const

Dump the state of the class.

int ACE_RW_Token::is_owner ( const ACE_TCHAR id)
virtual

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

Implements ACE_Tokens.

int ACE_RW_Token::is_waiting_for ( const ACE_TCHAR id)
virtual

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

Implements ACE_Tokens.

void ACE_RW_Token::notify_new_owner ( ACE_TPQ_Entry caller)
protected

Sets the new owner.

int ACE_RW_Token::owners ( OWNER_STACK o,
const ACE_TCHAR id 
)
virtual

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

Implements ACE_Tokens.

int ACE_RW_Token::release ( ACE_TPQ_Entry caller)
virtual

Relinquish the token. If there are any waiters then the next one in line gets it. If the caller is not the owner, caller is removed from the waiter list.

Implements ACE_Tokens.

int ACE_RW_Token::renew ( ACE_TPQ_Entry caller,
int  requeue_position 
)
virtual

An optimized method that efficiently reacquires the token if no other threads are waiting. This is useful for situations where you don't want to degrade the quality of service if there are other threads waiting to get the token. If <requeue_position> == -1 and there are other threads waiting to obtain the token we are queued at the end of the list of waiters. If <requeue_position>

-1 then it indicates how many entries to skip over before

inserting our thread into the list of waiters (e.g., <requeue_position> == 0 means "insert at front of the queue"). Renew has the rather odd semantics such that if there are other waiting threads it will give up the token even if the nesting_level_ > 1. I'm not sure if this is really the right thing to do (since it makes it possible for shared data to be changed unexpectedly) so use with caution... Returns 0 on success, -1 on failure with <ACE_Log_Msg::errnum> as the reason. If errnum == EWOULDBLOCK, and notify == 1, <ACE_Token_Proxy::sleep_hook> has been called on the current owner of the token.

Implements ACE_Tokens.

int ACE_RW_Token::tryacquire ( ACE_TPQ_Entry caller)
virtual

Same as acquire except fails on would block.

Implements ACE_Tokens.

int ACE_RW_Token::type ( void  ) const
virtual

Returns READER or WRITER.

Implements ACE_Tokens.

Member Data Documentation

ACE_TOKEN_CONST::MUTEX ACE_RW_Token::lock_
protected

ACE_Mutex_Token used to lock internal data structures.

int ACE_RW_Token::num_writers_
protected

The number of waiting writers.


The documentation for this class was generated from the following files: