Reference

ACE_Token_Invariant_Manager(3)

Token Invariants

NAME

ACE_Token_Invariant_Manager - Token Invariants

SYNOPSIS

#include <ace/Token_Invariants.h>
class ACE_Token_Invariant_Manager : public ACE_Cleanup
{
  public:
    static ACE_Token_Invariant_Manager *instance (void);
    int acquired (const ACE_Token_Proxy *proxy);
    void releasing (const ACE_Token_Proxy *proxy);
    int mutex_acquired (const ASYS_TCHAR *token_name);
    void mutex_releasing (const ASYS_TCHAR *token_name);
    int reader_acquired (const ASYS_TCHAR *token_name);
    int writer_acquired (const ASYS_TCHAR *token_name);
    void rwlock_releasing (const ASYS_TCHAR *token_name);
    void dump (void) const;
    ACE_Token_Invariant_Manager (void);
    virtual ~ACE_Token_Invariant_Manager (void);
  protected:
    int get_mutex (
        const ASYS_TCHAR *token_name,
        ACE_Mutex_Invariants *&inv
        );
    int get_rwlock (
        const ASYS_TCHAR *token_name,
        ACE_RWLock_Invariants *&inv
        );
    ACE_TOKEN_CONST::MUTEX lock_;
    typedef ACE_Token_Name TOKEN_NAME;
        typedef ACE_Map_Manager<TOKEN_NAME, ACE_Mutex_Invariants *, ACE_Null_Mutex> MUTEX_COLLECTION;
        
        typedef ACE_Map_Iterator<TOKEN_NAME, ACE_Mutex_Invariants *, ACE_Null_Mutex> MUTEX_COLLECTION_ITERATOR;
        
        typedef ACE_Map_Entry<TOKEN_NAME, ACE_Mutex_Invariants *> MUTEX_COLLECTION_ENTRY;
        
    MUTEX_COLLECTION mutex_collection_;
        typedef ACE_Map_Manager<TOKEN_NAME, ACE_RWLock_Invariants *, ACE_Null_Mutex> RWLOCK_COLLECTION;
        
        typedef ACE_Map_Iterator<TOKEN_NAME, ACE_RWLock_Invariants *, ACE_Null_Mutex> RWLOCK_COLLECTION_ITERATOR;
        
        typedef ACE_Map_Entry<TOKEN_NAME, ACE_RWLock_Invariants *> RWLOCK_COLLECTION_ENTRY;
        
    RWLOCK_COLLECTION rwlock_collection_;
    static ACE_Token_Invariant_Manager *instance_;
};

DESCRIPTION

Allows applications to test that invariants are always satisfied. Can test mutexes and readers/writer locks. Does not test recursive acquisition.

Polymorphic methods. Just pass in the proxy and the method

figures out the type of the token.

int acquired (const ACE_Token_Proxy *proxy);

Returns 1 on success, 0 when an invariant has been violated and -1 on error.

void releasing (const ACE_Token_Proxy *proxy);

Updates internal database.

Explicit methods. These to not require actual proxies in order

to test a scenario.

int mutex_acquired (const ASYS_TCHAR *token_name);

Returns 1 on success, 0 when an invariant has been violated and -1 on error.

void mutex_releasing (const ASYS_TCHAR *token_name);

Updates internal database.

int reader_acquired (const ASYS_TCHAR *token_name);

Returns 1 on success, 0 when an invariant has been violated and -1 on error.

int writer_acquired (const ASYS_TCHAR *token_name);

Returns 1 on success, 0 when an invariant has been violated and -1 on error.

void rwlock_releasing (const ASYS_TCHAR *token_name);

Updates internal database.

void dump (void) const;

Dump the state of the class.

The following two method should be in the protected part of the

class. Bugs with certain compilers preclude this.

ACE_Token_Invariant_Manager (void);

Prevent non-singleton construction.

virtual ~ACE_Token_Invariant_Manager (void);

Destruction.

AUTHOR

Tim Harrison ([email protected])

LIBRARY

ace