*Backed out changeset 3be01fb200a5
--HG-- branch : trunk
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
// -*- C++ -*-
|
||||
|
||||
//=============================================================================
|
||||
/**
|
||||
* @file Token_Collection.h
|
||||
@@ -18,17 +19,24 @@
|
||||
* @author Tim Harrison ([email protected])
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
#ifndef ACE_TOKEN_COLLECTION_H
|
||||
#define ACE_TOKEN_COLLECTION_H
|
||||
#include /**/ "ace/pre.h"
|
||||
|
||||
#include "ace/Map_Manager.h"
|
||||
|
||||
#if !defined (ACE_LACKS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif /* ACE_LACKS_PRAGMA_ONCE */
|
||||
|
||||
#if defined (ACE_HAS_TOKENS_LIBRARY)
|
||||
|
||||
#include "ace/Local_Tokens.h"
|
||||
#include "ace/Null_Mutex.h"
|
||||
|
||||
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
|
||||
|
||||
/**
|
||||
* @class ACE_Token_Collection
|
||||
*
|
||||
@@ -60,7 +68,9 @@ public:
|
||||
*/
|
||||
ACE_Token_Collection (bool debug = false,
|
||||
const ACE_TCHAR *name = 0);
|
||||
|
||||
// Collection Management operations
|
||||
|
||||
/**
|
||||
* Insert a Token into the collection. All ACE_Token type
|
||||
* operations performed on the collection will also be performed on
|
||||
@@ -74,6 +84,7 @@ public:
|
||||
* changed explicity on each proxy using is_member.
|
||||
*/
|
||||
int insert (ACE_Token_Proxy &token);
|
||||
|
||||
/**
|
||||
* Removes the ACE_Token matching the given token_name from the
|
||||
* collection. On success, extract returns 0. On failure
|
||||
@@ -82,15 +93,19 @@ public:
|
||||
* The returned ACE_Token_Proxy* must be deleted by the user.
|
||||
*/
|
||||
int extract (const ACE_TCHAR *token_name, ACE_Token_Proxy *&proxy);
|
||||
|
||||
/// Returns the proxy if true. 0 otherwise.
|
||||
ACE_Token_Proxy *is_member (const ACE_TCHAR *token_name);
|
||||
|
||||
/**
|
||||
* Is the specified token in the collection?
|
||||
* 1, yes.
|
||||
* 0, no.
|
||||
*/
|
||||
int is_member (const ACE_Token_Proxy &token);
|
||||
|
||||
// = Collective operation semantics.
|
||||
|
||||
// For acquire, renew, and release, there are two interfaces. Once
|
||||
// interface allows an operation on a single token in the
|
||||
// collection. The collective interfaces perform atomic operations
|
||||
@@ -101,6 +116,7 @@ public:
|
||||
// the Collection steps through the tokens in the order they were
|
||||
// inserted. For each one it performs the operation (acquire,
|
||||
// renew, or release).
|
||||
|
||||
/**
|
||||
* Acquire "atomically" all resources in the collection. This is
|
||||
* only successfull if all tokens in the collection could be
|
||||
@@ -119,6 +135,7 @@ public:
|
||||
void (*sleep_hook)(void *) = 0,
|
||||
ACE_Synch_Options &options =
|
||||
ACE_Synch_Options::defaults);
|
||||
|
||||
/// Acquire the token corresponding to @a token_name. The other
|
||||
/// parameters are passed to <token>::acquire.
|
||||
virtual int acquire (const ACE_TCHAR *token_name,
|
||||
@@ -126,11 +143,14 @@ public:
|
||||
void (*sleep_hook)(void *) = 0,
|
||||
ACE_Synch_Options &options =
|
||||
ACE_Synch_Options::defaults);
|
||||
|
||||
/// Try to acquire all tokens in collection.
|
||||
virtual int tryacquire (void (*sleep_hook)(void *) = 0);
|
||||
|
||||
/// Try to acquire @a token_name.
|
||||
virtual int tryacquire (const ACE_TCHAR *token_name,
|
||||
void (*sleep_hook)(void *) = 0);
|
||||
|
||||
/**
|
||||
* Renews "atomically" all resources in the collection. This is
|
||||
* only successfull if all tokens in the collection could be
|
||||
@@ -142,12 +162,14 @@ public:
|
||||
ACE_Synch_Options &options =
|
||||
ACE_Synch_Options::defaults);
|
||||
|
||||
|
||||
/// Renew the token corresponding to @a token_name. The other
|
||||
/// parameters are passed to <token>::renew.
|
||||
virtual int renew (const ACE_TCHAR *token_name,
|
||||
int requeue_position = 0,
|
||||
ACE_Synch_Options &options =
|
||||
ACE_Synch_Options::defaults);
|
||||
|
||||
/**
|
||||
* Releases "atomically" all resources in the collection. This is
|
||||
* only successfull if all tokens in the collection could be
|
||||
@@ -158,48 +180,65 @@ public:
|
||||
virtual int release (ACE_Synch_Options &options =
|
||||
ACE_Synch_Options::defaults);
|
||||
|
||||
|
||||
/// Release the token corresponding to <token_name>. The other
|
||||
/// parameters are passed to <token>::release.
|
||||
virtual int release (const ACE_TCHAR *token_name,
|
||||
ACE_Synch_Options &options =
|
||||
ACE_Synch_Options::defaults);
|
||||
|
||||
~ACE_Token_Collection (void);
|
||||
|
||||
/// Dump the state of the class.
|
||||
void dump (void) const;
|
||||
|
||||
/// Return the name of the collection. Not very functionally
|
||||
/// important, but sometimes a useful debugging tool.
|
||||
virtual const ACE_TCHAR *name (void) const;
|
||||
|
||||
protected:
|
||||
|
||||
typedef ACE_Token_Name TOKEN_NAME;
|
||||
|
||||
/// COLLECTION maintains a mapping from token names to ACE_Tokens*
|
||||
typedef ACE_Map_Manager<TOKEN_NAME, ACE_Token_Proxy *, ACE_Null_Mutex>
|
||||
COLLECTION;
|
||||
|
||||
/// Allows iterations through collection_
|
||||
/**
|
||||
* @deprecated Deprecated typedef. Use COLLECTION::ITERATOR trait instead.
|
||||
*/
|
||||
typedef COLLECTION::ITERATOR COLLECTION_ITERATOR;
|
||||
|
||||
/// Allows iterations through collection_
|
||||
/**
|
||||
* @deprecated Deprecated typedef. Use COLLECTION::ENTRY trait instead.
|
||||
*/
|
||||
typedef COLLECTION::ENTRY COLLECTION_ENTRY;
|
||||
|
||||
/// COLLECTION maintains a mapping from token names to ACE_Tokens*.
|
||||
COLLECTION collection_;
|
||||
|
||||
/// Whether to print out debug messages or not.
|
||||
bool debug_;
|
||||
|
||||
/// Name of the collection.
|
||||
ACE_TCHAR name_[ACE_MAXTOKENNAMELEN];
|
||||
|
||||
// = I'm not sure what these mean, but they have to be defined since they're
|
||||
// pure virtual in ACE_Token_Proxy.
|
||||
virtual ACE_Token_Proxy *clone (void) const;
|
||||
virtual ACE_Tokens *create_token (const ACE_TCHAR *name);
|
||||
};
|
||||
|
||||
ACE_END_VERSIONED_NAMESPACE_DECL
|
||||
|
||||
#if defined (__ACE_INLINE__)
|
||||
#include "ace/Token_Collection.inl"
|
||||
#endif /* __ACE_INLINE__ */
|
||||
|
||||
#endif /* ACE_HAS_TOKENS_LIBRARY */
|
||||
|
||||
#include /**/ "ace/post.h"
|
||||
#endif /* ACE_TOKEN_COLLECTION_H */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user