## NAME

ACE_Tokens - Abstract representation of ACE tokens.

## SYNOPSIS

    #include <ace/Local_Tokens.h>

    class ACE_Tokens
    {
      public:
        ACE_Tokens (void);
        virtual ~ACE_Tokens (void);
        virtual int acquire (
            ACE_TPQ_Entry *caller,
            int ignore_deadlock,
            int notify
            ) = 0;
        virtual int tryacquire (ACE_TPQ_Entry *caller) = 0;
        virtual int renew (
            ACE_TPQ_Entry *caller,
            int requeue_position
            ) = 0;
        virtual int release (ACE_TPQ_Entry *caller) = 0;
        void make_owner (ACE_TPQ_Entry *caller);
        void remove (ACE_TPQ_Entry *caller);
        typedef ACE_Unbounded_Stack<ACE_TPQ_Entry *> OWNER_STACK;
        virtual int owners (OWNER_STACK &o, const ASYS_TCHAR *id) = 0;
        virtual int is_waiting_for (const ASYS_TCHAR *id) = 0;
        virtual int is_owner (const ASYS_TCHAR *id) = 0;
        virtual ACE_Token_Proxy_Queue *waiters (void);
        virtual int no_of_waiters (void);
        const ASYS_TCHAR *owner_id (void);
        const ASYS_TCHAR* name (void);
        void inc_reference (void);
        int dec_reference (void);
        void dump (void) const;
        enum TOKEN_TYPES { MUTEX, RWLOCK };
        virtual int type (void) const = 0;
        void visit (int v);
        int visited (void);
        ACE_TPQ_Entry *owner (void);
      protected:
        int visited_;
        int reference_count_;
        ACE_Token_Proxy_Queue waiters_;
        ASYS_TCHAR token_name_[ACE_MAXTOKENNAMELEN];
    };

## DESCRIPTION

This file contains definitions for the following classes:

public: 7. ACE_Token_Proxy 8. ACE_Null_Token : public ACE_Token_Proxy 9. ACE_Local_Mutex : public ACE_Token_Proxy *. ACE_Local_RLock : public ACE_Local_Mutex &. ACE_Local_WLock : public ACE_Local_Mutex private: 1. ACE_TOKEN_CONST 3. ACE_TPQ_Entry b. ACE_TSS_TPQ_Entry c. ACE_TPQ_Iterator 4. ACE_Token_Proxy_Queue 5. ACE_Tokens 6. ACE_Mutex_Token : public ACE_Tokens 12. ACE_RW_Token : public ACE_Tokens a. ACE_Token_Name

## Accessor methods.

    typedef ACE_Unbounded_Stack<ACE_TPQ_Entry *> OWNER_STACK;

Stack of owners.

    virtual int owners (OWNER_STACK &o, const ASYS_TCHAR *id) = 0;

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.

    virtual int is_waiting_for (const ASYS_TCHAR *id) = 0;

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

    virtual int is_owner (const ASYS_TCHAR *id) = 0;

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

    virtual ACE_Token_Proxy_Queue *waiters (void);

Return the queue of waiters.

    virtual int no_of_waiters (void);

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

    const ASYS_TCHAR *owner_id (void);

The current owner.

    const ASYS_TCHAR* name (void);

Token name.

## Reference counting. These are only called by the

Token_Manager.

    void inc_reference (void);

    int dec_reference (void);

    void dump (void) const;

Dump the state of the class.

    virtual int type (void) const = 0;

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.

## The following methods allow the deadlock detection algorithm to

check if this token has been visited.

    void visit (int v);

Mark or unmark the token as visited.

    int visited (void);

Check if the token has been visited.

    ACE_TPQ_Entry *owner (void);

All the data of the current owner.

## AUTHOR

Karl-Heinz Dorn (kdorn@erlh.siemens.de) Douglas C. Schmidt (schmidt@cs.wustl.edu) Tim Harrison (harrison@cs.wustl.edu)

## LIBRARY

ace