Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The latest version of this topic can be found at sync_shared Class.
Describes a synchronization filter that uses a mutex to control access to a cache object that is shared by all allocators.
Syntax
template <class Cache>
class sync_shared
Parameters
| Parameter | Description |
|---|---|
Cache |
The type of cache associated with the synchronization filter. This can be cache_chunklist, cache_freelist, or cache_suballoc. |
Member Functions
| allocate | Allocates a block of memory. |
| deallocate | Frees a specified number of objects from storage beginning at a specified position. |
| equals | Compares two caches for equality. |
Requirements
Header: <allocators>
Namespace: stdext
sync_shared::allocate
Allocates a block of memory.
void *allocate(std::size_t count);
Parameters
| Parameter | Description |
|---|---|
count |
The number of elements in the array to be allocated. |
Return Value
A pointer to the allocated object.
Remarks
The member function locks the mutex, calls cache.allocate(count), unlocks the mutex, and returns the result of the earlier call to cache.allocate(count). cache represents the current cache object.
sync_shared::deallocate
Frees a specified number of objects from storage beginning at a specified position.
void deallocate(void* ptr, std::size_t count);
Parameters
| Parameter | Description |
|---|---|
ptr |
A pointer to the first object to be deallocated from storage. |
count |
The number of objects to be deallocated from storage. |
Remarks
This member function locks the mutex, calls cache.deallocate(ptr, count), where cache represents the cache object, and then unlocks the mutex.
sync_shared::equals
Compares two caches for equality.
bool equals(const sync_shared<Cache>& Other) const;
Parameters
| Parameter | Description |
|---|---|
Cache |
The type of cache associated with the synchronization filter. |
Other |
The cache to compare for equality. |
Return Value
true if the result of cache.equals(Other.cache), where cache represents the cache object, is true; otherwise, false.