com.r3corda.node.services.statemachine / ProtocolStateMachineImpl

# ProtocolStateMachineImpl

`class ProtocolStateMachineImpl<R> : ProtocolStateMachine<R>`

A ProtocolStateMachine instance is a suspendable fiber that delegates all actual logic to a ProtocolLogic instance. For any given flow there is only one PSM, even if that protocol invokes subprotocols.

These classes are created by the StateMachineManager when a new protocol is started at the topmost level. If a protocol invokes a sub-protocol, then it will pass along the PSM to the child. The call method of the topmost logic element gets to return the value that the entire state machine resolves to.

### Constructors

<init> | `ProtocolStateMachineImpl(logic: ProtocolLogic<R>, scheduler: <ERROR CLASS>, loggerName: String)` A ProtocolStateMachine instance is a suspendable fiber that delegates all actual logic to a ProtocolLogic instance. For any given flow there is only one PSM, even if that protocol invokes subprotocols.

### Properties

logger | `val logger: <ERROR CLASS>`
logic | `val logic: ProtocolLogic<R>`
resultFuture | `val resultFuture: <ERROR CLASS><R>` This future will complete when the call method returns.
serviceHub | `lateinit var serviceHub: ServiceHubInternal`

### Functions

prepareForResumeWith | `fun prepareForResumeWith(serviceHub: ServiceHubInternal, receivedPayload: Any?, suspendAction: (FiberRequest, ProtocolStateMachineImpl<*>) -> Unit): Unit`
receive | `fun <T : Any> receive(topic: String, sessionIDForReceive: Long, recvType: Class<T>): UntrustworthyData<T>`
run | `fun run(): R`
send | `fun send(topic: String, destination: MessageRecipients, sessionID: Long, obj: Any): Unit`
sendAndReceive | `fun <T : Any> sendAndReceive(topic: String, destination: MessageRecipients, sessionIDForSend: Long, sessionIDForReceive: Long, obj: Any, recvType: Class<T>): UntrustworthyData<T>`