IThreadLocalBase
- IThreadLocalBase is abstract base class, from which the IThreadLocalStorage template class is derived. IThreadLocalStorage is the
class that you should use per-thread data storage. IThreadLocalBase just provides some common code that could be pushed out of
line and thus not redundantly replicated for every instantiation of IThreadLocalStorage. It manages the magic internal data structures
that track per-thread data objects.
IThreadLocalBase - Member Functions and Data by Group
Constructors & Destructor
Construct and destruct objects of this class.
- ~IThreadLocalBase
protected:
virtual ~IThreadLocalBase()
- Destroys the thread local base object.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
- IThreadLocalBase
protected:
IThreadLocalBase()
- The default constructor is the only available constructor.
- The default constructor just sets the next field to zero.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
Slot Management Methods
These methods are internal implementation methods for managing the per thread
data slots used by this class to store data.
- expandThreadSlots
protected:
void expandThreadSlots(const unsigned long newcount)
- This method is called to expand the number of 'slots' for the calling thread. The number of slots is the number of pointers in the internal list
maintained by this class. Each thread local storage object requires a slot for each thread that exists. To avoid excessive expansion, the
slot list is actually expanded by an increment value, not just up to the passed count necessarily.
- newcount
- is the new number of slots needed. This is only advisory and the actual slot count is rounded up to the next
internal expansion increment.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
- getNextSlot
protected:
unsigned long getNextSlot()
- This method is used internally for slot management. It will find the next unused slot on the calling thread, expanding the slot list if that is required.
It does any required synchronization to insure that global resources are accessed in a thread safe way.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
- getSlot
protected:
void* getSlot(const unsigned long index) const
- This method returns the pointer value in the indicated slot for the calling thread. Note that it does not actually expand the slot list, since it can just
return zero if that slot does not yet exist for this thread. Only the setting of a slot requires that the list actually be expanded. Each thread local object
stores its index to the slot list, so the value passed is that stored index.
- index
- is the index of the slot (of the calling thread) to get the pointer from.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
- setSlot
protected:
void setSlot(const unsigned long index, void* data)
- Sets the passed data pointer into the indicated per thread data slot.
- index
- is the index of the slot for the calling thread that is to be set.
- data
- is the data pointer to put into the indicated slot.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
Storage Management Methods
These methods manage the data pointer stored in thread local storage objects.
- freeAllStorage
public:
static void freeAllStorage()
- This method is called to free all of the data associated with a thread. It should be called as the very last thing that a thread does, otherwise it
might free memory before other code called on that thread is done with it.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
- freeStorage
protected:
virtual void freeStorage() = 0
- This is a virtual method that each instantiation of the derived class, IThreadLocalStorage, overrides. Since the type of the data object stored
is only known by the derived template class, this method cannot be implemented at the IThreadLocalBase level. However, internally, storage
can be freed via the base class, which allows the internal implementation to maintain a list of all thread local storage objects by way of the
IThreadLocalBase interface and still be able to clean up the associated data.
- Supported Platforms
| Windows |
OS/2 |
AIX |
| Yes |
Yes |
Yes |
IThreadLocalBase - Inherited Member Functions and Data
Inherited Public Functions
Inherited Public Data
Inherited Protected Functions
- IThreadLocalBase
-
Inherited Protected Data