You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added the SharedBitmappedBlock, as the thread-safe version of the regular BitmappedBlock.
2
+
3
+
The new $(REF SharedBitmappedBlock, std,experimental,allocator,building_blocks,bitmapped_block) and its single-threaded version can now be instantiated with `Yes.multiblock` or `No.multiblock`.
4
+
If instantiated with `Yes.multiblock` (the default behavior), each allocation can return an arbitrary number of blocks.
5
+
With `No.multiblock` however, any allocation request can't exceed the block size. This allows for greater performance on both single and multithreaded environments.
6
+
7
+
---
8
+
// The 'BitmappedBlock' is implicitly instantiated with Yes.multiblock
9
+
auto a = BitmappedBlock!(blockSize, 8, Mallocator, Yes.multiblock)(numBlocks * blockSize);
10
+
11
+
// Instantiated with Yes.multiblock, can allocate more than one block at a time
12
+
void[] buf = a.allocate(2 * blockSize);
13
+
assert(buf.length == 2 * blockSize);
14
+
assert(a.deallocate(buf));
15
+
---
16
+
17
+
---
18
+
// Instantate the 'BitmappedBlock' with No.multiblock
19
+
auto a = BitmappedBlock!(blockSize, 8, Mallocator, No.multiblock)(1024 * blockSize);
20
+
21
+
// Since instantiated with No.multiblock, can only allocate at most the block size
22
+
void[] buf = a.allocate(blockSize + 1);
23
+
assert(buf is null);
24
+
---
25
+
26
+
For shared the same rules apply, we only need to replace `BitmappedBlock` with `SharedBitmappedBlock`.
0 commit comments