class FlatBuffer
Swift
class FlatBuffer
Swift wrapper for nprpc::flat_buffer Marked as @unchecked Sendable because ownership is explicitly transferred between tasks and the underlying C++ memory is safely encapsulated.
Owned buffers use a C++ per-thread free-list (nprpc_flatbuffer_acquire /
release) so repeated RPCs recycle heap capacity instead of new/delete
every call. Safe with async: send_receive_async moves storage into the
session; the empty shell returns to the pool on deinit.
nprpc_swift/Sources/NPRPC/FlatBuffer.swift:14
Constructors
init()
Create a FlatBuffer from the per-thread pool (Swift owns it).
nprpc_swift/Sources/NPRPC/FlatBuffer.swift:20
Properties
var constData: UnsafeRawPointer? { get }
Get const data pointer for reading
nprpc_swift/Sources/NPRPC/FlatBuffer.swift:53
var data: UnsafeMutableRawPointer? { get }
Get mutable data pointer for writing
nprpc_swift/Sources/NPRPC/FlatBuffer.swift:48
var handle: UnsafeMutableRawPointer
The C++ flat_buffer this wraps, for bridge calls.
nprpc_swift/Sources/NPRPC/FlatBuffer.swift:16
var size: Int { get }
Get buffer size
nprpc_swift/Sources/NPRPC/FlatBuffer.swift:58
Methods
static func acquire() -> FlatBuffer
Explicit pool acquire (same as init(); kept for call sites that want
the intent spelled out next to release()).
nprpc_swift/Sources/NPRPC/FlatBuffer.swift:27
func commit(_ n: Int)
Commit written data
nprpc_swift/Sources/NPRPC/FlatBuffer.swift:74
func consume(_ n: Int)
Consume data
nprpc_swift/Sources/NPRPC/FlatBuffer.swift:79
func prepare(_ n: Int)
Prepare space for writing
nprpc_swift/Sources/NPRPC/FlatBuffer.swift:69
func storeBytes<T>(of value: T, toByteOffset offset: Int, as type: T.Type)
Store a scalar using a freshly fetched data pointer so callers remain safe across reallocations.
nprpc_swift/Sources/NPRPC/FlatBuffer.swift:63