| description | Learn more about: sync_shared Class | ||||
|---|---|---|---|---|---|
| title | sync_shared Class | ||||
| ms.date | 11/04/2016 | ||||
| f1_keywords |
|
||||
| helpviewer_keywords |
|
||||
| ms.assetid | cab3af9e-3d1a-4f2c-8580-0f89e5687d8e |
Describes a synchronization filter that uses a mutex to control access to a cache object that is shared by all allocators.
template <class Cache>
class sync_sharedCache
The type of cache associated with the synchronization filter. It can be cache_chunklist, cache_freelist, or cache_suballoc.
| Member function | Description |
|---|---|
| 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. |
Header: <allocators>
Namespace: stdext
Allocates a block of memory.
void *allocate(std::size_t count);count
The number of elements in the array to be allocated.
A pointer to the allocated object.
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.
Frees a specified number of objects from storage beginning at a specified position.
void deallocate(void* ptr, std::size_t count);ptr
A pointer to the first object to be deallocated from storage.
count
The number of objects to be deallocated from storage.
This member function locks the mutex, calls cache.deallocate(ptr, count), where cache represents the cache object, and then unlocks the mutex.
Compares two caches for equality.
bool equals(const sync_shared<Cache>& Other) const;Cache
The type of cache associated with the synchronization filter.
Other
The cache to compare for equality.
true if the result of cache.equals(Other.cache), where cache represents the cache object, is true; otherwise, false.