NPRPC docs

class Poa

Swift

final class Poa

Portable Object Adapter - manages servant lifecycle

POAs are containers for servants (object implementations). They:

  • Assign object IDs to servants
  • Route incoming requests to the correct servant
  • Control which transports servants are accessible on
  • Manage servant lifecycle (activation/deactivation)

Example:

// Background / high-throughput servants (default)
let poa = try rpc.createPoa(maxObjects: 100)

// UI servants — dispatch lands on the main queue
let uiPoa = try rpc.createPoa(
    maxObjects: 32,
    dispatch: .main
)

let servant = MyServantImpl()
let objectId = try uiPoa.activateObject(servant, flags: .networkOnly)

nprpc_swift/Sources/NPRPC/Poa.swift:316

Properties

var index: UInt16 { get }

POA index

nprpc_swift/Sources/NPRPC/Poa.swift:336

Methods

func activateObject(_ servant: NPRPCServant, flags: ObjectActivationFlags, sessionContext: UnsafeMutableRawPointer? = nil) throws -> detail.ObjectId

Activate a servant in this POA

  • Throws: RuntimeError if activation fails
servant
The servant to activate
flags
Transport flags controlling how the object is accessible
sessionContext
Optional session context for session-specific activation

Returns ObjectId data for the activated object

nprpc_swift/Sources/NPRPC/Poa.swift:347

func activateObjectWithId(objectId: UInt64, servant: NPRPCServant, flags: ObjectActivationFlags, sessionContext: UnsafeMutableRawPointer? = nil) throws -> detail.ObjectId

Activate a servant under an id you choose. The POA must use ObjectIdPolicy.userSupplied.

  • Throws: RuntimeError if activation fails
objectId
The id to activate the servant under
servant
The servant to activate
flags
Transport flags controlling how the object is accessible
sessionContext
Optional session context for session-specific activation

Returns ObjectId data for the activated object

nprpc_swift/Sources/NPRPC/Poa.swift:397

func deactivateObject(_ objectId: UInt64)

Deactivate an object by its ID

objectId
The object ID to deactivate

nprpc_swift/Sources/NPRPC/Poa.swift:442