#include <ace/Local_Tokens> class ACE_RW_Token : public ACE_Tokens {
public:
ACE_RW_Token (const char* name);
~ACE_RW_Token (void);
virtual int acquire ( ACE_TPQ_Entry *caller, int ignore_deadlock, int notify );
virtual int tryacquire (ACE_TPQ_Entry *caller);
virtual int renew (ACE_TPQ_Entry *caller, int requeue_position);
virtual int release (ACE_TPQ_Entry *caller);
void dump (void) const;
enum PROXY_TYPE { READER, WRITER };
virtual int type (void) const;
virtual int owners (OWNER_STACK &o, const char *id);
virtual int is_waiting_for (const char *id);
virtual int is_owner (const char *id);
protected:
int num_writers_;
ACE_TOKEN_CONST::MUTEX lock_;
void notify_new_owner (ACE_TPQ_Entry *caller);
};
virtual int acquire (
ACE_TPQ_Entry *caller,
int ignore_deadlock,
int notify
);
virtual int tryacquire (ACE_TPQ_Entry *caller);
virtual int renew (ACE_TPQ_Entry *caller, int requeue_position);
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.
virtual int release (ACE_TPQ_Entry *caller);
void dump (void) const;
virtual int type (void) const;
virtual int owners (OWNER_STACK &o, const char *id);
id
is non-zero, returns 1 if id is an owner.
virtual int is_waiting_for (const char *id);
id
is waiting for this token. 0 otherwise.
virtual int is_owner (const char *id);
id
is an owner of this token. 0 otherwise.