Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_TSS_Keys Class Reference

Collection of in-use flags for a thread's TSS keys. For internal use only by ACE_TSS_Cleanup; it is public because some compilers can't use nested classes for template instantiation parameters. More...

#include <OS.h>

List of all members.

Public Methods

 ACE_TSS_Keys (void)
 Default constructor, to initialize all bits to zero (unused). More...

int test_and_set (const ACE_thread_key_t key)
 Mark the specified key as being in use, if it was not already so marked. Returns 1 if the had already been marked, 0 if not. More...

int test_and_clear (const ACE_thread_key_t key)
 Mark the specified key as not being in use, if it was not already so cleared. Returns 1 if the key had already been cleared, 0 if not. More...

int is_set (const ACE_thread_key_t key) const
 Return whether the specific key is marked as in use. Returns 1 if the key is been marked, 0 if not. More...


Private Types

enum  { ACE_WORDS = (ACE_DEFAULT_THREAD_KEYS - 1) / ACE_BITS_PER_WORD + 1 }

Static Private Methods

void find (const u_int key, u_int &word, u_int &bit)
 For a given key, find the word and bit number that represent it. More...


Private Attributes

u_long key_bit_words_ [ACE_WORDS]
 Bit flag collection. A bit value of 1 indicates that the key is in use by this thread. More...


Detailed Description

Collection of in-use flags for a thread's TSS keys. For internal use only by ACE_TSS_Cleanup; it is public because some compilers can't use nested classes for template instantiation parameters.

Wrapper around array of whether each key is in use. A simple typedef doesn't work with Sun C++ 4.2.

Definition at line 6605 of file OS.h.


Member Enumeration Documentation

anonymous enum [private]
 

Enumeration values:
ACE_WORDS 

Definition at line 6627 of file OS.h.

06628     {
06629 #   if ACE_SIZEOF_LONG == 8
06630       ACE_BITS_PER_WORD = 64,
06631 #   elif ACE_SIZEOF_LONG == 4
06632       ACE_BITS_PER_WORD = 32,
06633 #   else
06634 #     error ACE_TSS_Keys only supports 32 or 64 bit longs.
06635 #   endif /* ACE_SIZEOF_LONG == 8 */
06636       ACE_WORDS = (ACE_DEFAULT_THREAD_KEYS - 1) / ACE_BITS_PER_WORD + 1
06637     };


Constructor & Destructor Documentation

ACE_TSS_Keys::ACE_TSS_Keys void   
 

Default constructor, to initialize all bits to zero (unused).

Definition at line 1716 of file OS.cpp.

References ACE_WORDS, and key_bit_words_.

01717 {
01718   for (u_int i = 0; i < ACE_WORDS; ++i)
01719     {
01720       key_bit_words_[i] = 0;
01721     }
01722 }


Member Function Documentation

ACE_SPECIAL_INLINE void ACE_TSS_Keys::find const u_int    key,
u_int &    word,
u_int &    bit
[static, private]
 

For a given key, find the word and bit number that represent it.

Definition at line 1726 of file OS.cpp.

Referenced by is_set, test_and_clear, and test_and_set.

01727 {
01728   word = key / ACE_BITS_PER_WORD;
01729   bit = key % ACE_BITS_PER_WORD;
01730 }

int ACE_TSS_Keys::is_set const ACE_thread_key_t    key const
 

Return whether the specific key is marked as in use. Returns 1 if the key is been marked, 0 if not.

Definition at line 1769 of file OS.cpp.

References ACE_BIT_ENABLED, ACE_KEY_INDEX, ACE_thread_key_t, find, and key_bit_words_.

01770 {
01771   ACE_KEY_INDEX (key_index, key);
01772   u_int word, bit;
01773   find (key_index, word, bit);
01774 
01775   return ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit);
01776 }

int ACE_TSS_Keys::test_and_clear const ACE_thread_key_t    key
 

Mark the specified key as not being in use, if it was not already so cleared. Returns 1 if the key had already been cleared, 0 if not.

Definition at line 1751 of file OS.cpp.

References ACE_BIT_ENABLED, ACE_CLR_BITS, ACE_KEY_INDEX, ACE_thread_key_t, find, and key_bit_words_.

Referenced by ACE_TSS_Cleanup::exit, and ACE_TSS_Cleanup::remove.

01752 {
01753   ACE_KEY_INDEX (key_index, key);
01754   u_int word, bit;
01755   find (key_index, word, bit);
01756 
01757   if (ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit))
01758     {
01759       ACE_CLR_BITS (key_bit_words_[word], 1 << bit);
01760       return 0;
01761     }
01762   else
01763     {
01764       return 1;
01765     }
01766 }

int ACE_TSS_Keys::test_and_set const ACE_thread_key_t    key
 

Mark the specified key as being in use, if it was not already so marked. Returns 1 if the had already been marked, 0 if not.

Definition at line 1733 of file OS.cpp.

References ACE_BIT_ENABLED, ACE_KEY_INDEX, ACE_SET_BITS, ACE_thread_key_t, find, and key_bit_words_.

Referenced by ACE_TSS_Cleanup::key_used.

01734 {
01735   ACE_KEY_INDEX (key_index, key);
01736   u_int word, bit;
01737   find (key_index, word, bit);
01738 
01739   if (ACE_BIT_ENABLED (key_bit_words_[word], 1 << bit))
01740     {
01741       return 1;
01742     }
01743   else
01744     {
01745       ACE_SET_BITS (key_bit_words_[word], 1 << bit);
01746       return 0;
01747     }
01748 }


Member Data Documentation

u_long ACE_TSS_Keys::key_bit_words_[ACE_WORDS] [private]
 

Bit flag collection. A bit value of 1 indicates that the key is in use by this thread.

Definition at line 6641 of file OS.h.

Referenced by ACE_TSS_Keys, is_set, test_and_clear, and test_and_set.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:58:43 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002