-
Capacity of this storage instance, in bytes
Declaration
Swift
let capacity: Int -
Pointer to our allocated memory
Declaration
Swift
var storagePointer: UnsafeMutableRawPointer! -
Base address of the storage, as mapped to UInt8
Declaration
Swift
var baseAddress: UnsafeMutablePointer<UInt8>? -
Create an instance of
RingBufferStorage, with a givencapacity, usingallocatorto allocate the memory.Declaration
Swift
init(capacity: Int)Parameters
capacityThe capacity of the storage to allocate
-
Deallocate our storage, if it exists, upon deinitialization
Declaration
Swift
deinit
-
Calls a closure with a pointer to the buffer’s contiguous storage.
The UnsafeBufferPointer passed to the block will begin at the start address and continue for the entire capacity of the storage, even if the elements are nil.
Seealso
withUnsafeMutableBufferPointer,UnsafeBufferPointerDeclaration
Swift
func withUnsafeBufferPointer<ContentType, ResultType>( _ body: (UnsafeBufferPointer<ContentType>) throws -> ResultType ) rethrows -> ResultTypeParameters
bodyA closure with an
UnsafeBufferPointerparameter that points to the contiguous storage. Ifbodyhas a return value, it is used as the return value for thewithUnsafeBufferPointer(_:)method. The pointer argument is valid only for the duration of the closure’s execution.Return Value
The return value of the
bodyclosure parameter, if any. -
Calls a closure with a pointer to the buffer’s mutable contiguous storage.
The UnsafeBufferPointer passed to the block will begin at the start address and continue for the entire capacity of the storage, even if the elements are nil.
Warning
Do not rely on anything about
self(the buffer that is the target of this method) during the execution of thebodyclosure: It may not appear to have its correct value. Instead, use only theUnsafeMutableBufferPointerargument tobody.Seealso
withUnsafeBufferPointer,UnsafeMutableBufferPointer,withUnsafeBytes,withUnsafeMutableBytesDeclaration
Swift
func withUnsafeMutableBufferPointer<ContentType, ResultType>( _ body: (UnsafeMutableBufferPointer<ContentType>) throws -> ResultType ) rethrows -> ResultTypeParameters
bodyA closure with an
UnsafeMutableBufferPointerparameter that points to the contiguous storage for the buffer. Ifbodyhas a return value, it is used as the return value for thewithUnsafeMutableBufferPointer(_:)method. The pointer argument is valid only for the duration of the closure’s execution.Return Value
The return value of the
bodyclosure parameter, if any. -
Access the bytes in the data.
Warning
The byte pointer argument should not be stored and used outside of the lifetime of the call to the closure.Declaration
Swift
func withUnsafeBytes<ContentType, ResultType>( _ body: (UnsafePointer<ContentType>) throws -> ResultType ) rethrows -> ResultType -
Mutate the bytes in the data.
This function assumes that you are mutating the contents. - warning: The byte pointer argument should not be stored and used outside of the lifetime of the call to the closure.
Declaration
Swift
func withUnsafeMutableBytes<ContentType, ResultType>( _ body: (UnsafeMutablePointer<ContentType>) throws -> ResultType ) rethrows -> ResultType
View on GitHub
RingBufferStorage Class Reference