-
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
, usingallocator
to allocate the memory.Declaration
Swift
init(capacity: Int)
Parameters
capacity
The 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
,UnsafeBufferPointer
Declaration
Swift
func withUnsafeBufferPointer<ContentType, ResultType>( _ body: (UnsafeBufferPointer<ContentType>) throws -> ResultType ) rethrows -> ResultType
Parameters
body
A closure with an
UnsafeBufferPointer
parameter that points to the contiguous storage. Ifbody
has 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
body
closure 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 thebody
closure: It may not appear to have its correct value. Instead, use only theUnsafeMutableBufferPointer
argument tobody
.Seealso
withUnsafeBufferPointer
,UnsafeMutableBufferPointer
,withUnsafeBytes
,withUnsafeMutableBytes
Declaration
Swift
func withUnsafeMutableBufferPointer<ContentType, ResultType>( _ body: (UnsafeMutableBufferPointer<ContentType>) throws -> ResultType ) rethrows -> ResultType
Parameters
body
A closure with an
UnsafeMutableBufferPointer
parameter that points to the contiguous storage for the buffer. Ifbody
has 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
body
closure 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