---
name: "ACE_Tokens"
section: "3"
platform: "linux"
package: "libace-doc"
version: "5.0.7-4"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/ACE_Tokens"
---

# ACE\_Tokens(3)

Abstract representation of ACE tokens.

## 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

 Note that the locking classes defined in this file are \*not\*\
  intended to be used as general-purpose synchronization\
  mechanisms, such as mutexes or semaphores.  Instead, you should\
  use the ACE\_Recursive\_Thread\_Mutex, ACE\_Thread\_Mutex,\
  ACE\_Thread\_Semaphore, etc., that are defined in\
  $ACE\_ROOT/ace/Synch.h and $ACE\_ROOT/ace/Synch\_T.h or the\
  ACE\_Token that's defined in $ACE\_ROOT/ace/Token.h.

## 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, and Tim Harrison harrison@cs.wustl.edu

## LIBRARY

ace
