View source code
							
							
						
								Display the source code in std/experimental/allocator/building_blocks/bitmapped_block.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								Improve this page
							
							
					
								Quickly fork, edit online, and submit a pull request for this page.
								Requires a signed-in GitHub account. This works well for small changes.
								If you'd like to make larger changes you may want to consider using
								local clone.
							
						Struct std.experimental.allocator.building_blocks.bitmapped_block.SharedBitmappedBlock
The threadsafe version of the BitmappedBlock.
The semantics of the SharedBitmappedBlock are identical to the regular BitmappedBlock.
						
				struct SharedBitmappedBlock(ulong theBlockSize, uint theAlignment = platformAlignment, ParentAllocator, Flag!("multiblock") f = Yes
				Constructors
| Name | Description | 
|---|---|
| this(data) | Constructs a block allocator given a hunk of memory, or a desired capacity
        in bytes. 
 | 
Fields
| Name | Type | Description | 
|---|---|---|
| parent | ParentAllocator | The parent allocator. Depending on whether ParentAllocatorholds state
        or not, this is a member variable or an alias forParentAllocator. | 
Methods
| Name | Description | 
|---|---|
| alignedAllocate(n, a) | Allocates a block with specified alignment a. The alignment must be a
        power of 2. Ifa <= alignment, function forwards toallocate.
        Otherwise, it attempts to overallocate and then adjust the result for
        proper alignment. In the worst case the slack memory is around two blocks. | 
| alignedReallocate(b, newSize, a) | Reallocates a block previously allocated with alignedAllocate. Contractions do not occur in place. | 
| allocate(s) | Allocates sbytes of memory and returns it, ornullif memory
        could not be allocated. | 
| allocateAll() | If the SharedBitmappedBlockobject is empty (has no active allocation), allocates
        all memory within and returns a slice to it. Otherwise, returnsnull(i.e. no attempt is made to allocate the largest available block). | 
| allocateFresh(s) | Allocates s bytes of memory and returns it, or nullif memory could not be allocated.allocateFreshbehaves just like allocate, the only difference being that this always
        returns unused(fresh) memory. Although there may still be available space in theSharedBitmappedBlock,allocateFreshcould still return null, because all the available blocks have been previously deallocated. | 
| deallocate(b) | Deallocates the given buffer b, by atomically setting the corresponding
        bit to0.bmust be valid, and cannot contain multiple adjacentblocks. | 
| deallocateAll() | Forcibly deallocates all memory allocated by this allocator, making it
        available for further allocations. Does not return memory to ParentAllocator. | 
| empty() | Returns Ternaryif no memory is currently allocated with this
        allocator, otherwiseTernary. This method never returnsTernary. | 
| expand(b, delta) | Expands in place a buffer previously allocated by SharedBitmappedBlock.
        Expansion fails if the new length exceeds the block size. | 
| goodAllocSize(n) | Returns the actual bytes allocated when nbytes are requested, i.e.n. | 
| owns(b) | Returns Ternaryifbbelongs to theSharedBitmappedBlockobject,Ternaryotherwise. Never returnsTernary. (This
        method is somewhat tolerant in that accepts an interior slice.) | 
| reallocate(b, newSize) | Reallocates a previously-allocated block. Contractions occur in place. | 
Aliases
| Name | Description | 
|---|---|
| alignment | The alignment offered is user-configurable statically through parameter theAlignment, defaulted toplatformAlignment. | 
| blockSize | If blockSize == chooseAtRuntime,SharedBitmappedBlockoffers a read/write
        propertyblockSize. It must be set before any use of the allocator.
        Otherwise (i.e.theBlockSizeis a legit constant),blockSizeis
        an alias fortheBlockSize. Whether constant or variable, must also be
        a multiple ofalignment. This constraint isasserted statically
        and dynamically. | 
Parameters
| Name | Description | 
|---|---|
| theBlockSize | the length of a block, which must be a multiple of theAlignment | 
| theAlignment | alignment of each block | 
| ParentAllocator | allocator from which the BitmappedBlockwill draw memory.
        If set toNullAllocator, the storage must be passed via the constructor | 
| f | Yesto support allocations spanning across multiple blocks andNoto support single block allocations.
        Although limited by single block allocations,Nowill generally
        provide higher performance. | 
Example
import stdAuthors
License
					Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.