The state model for peer-to-peer streams defines the conditions under which the stream can move from one state to another and coordinates the writer, reader, and host.
The peer-to-peer stream has the following states:
Transitions between two states can be non-blocking or blocking. Non-blocking transitions, such as the transition from Enabled to Flushing, occur immediately. Blocking transitions, such as from Unlinked to Disabled, halt the application until the reader or writer completes the necessary tasks. For example, when a stream transitions from Unlinked to Disabled, it must wait on the writer or reader to initialize. Non-blocking transitions for the writer and reader occur before the next clock cycle. Blocking transitions might not finish for several clock cycles.
The following table lists the types of transitions, the blocking characteristics of the transition, and the host application VIs that can perform the transition.
Transition | Type | Function |
---|---|---|
Unlinked to Disabled | Blocking | nip2pCreateAndLinkStream |
Disabled to Enabled | Blocking | nip2pEnableStream |
Enabled to Flushing | Non-Blocking | nip2pFlushAndDisableStream |
Flushing to Disabled | Blocking | nip2pFlushAndDisableStream |
Enabled to Disabled | Blocking | nip2pDisableStream |
Disabled to Unlinked | Non-Blocking | nip2pUnlinkStream |
The state of the host matches the state of the stream. The host application can monitor all states of the stream and control the transitions between the stream states. When the host application begins, the stream is in an Unlinked state. The host application then transitions the stream into other states using the Peer-To-Peer Streaming functions. The following illustration shows the stream states and the transitions that the host can control.
The state of the writer matches the state of the stream, but the writer cannot control all the transitions between the stream states. When the host links the writer and reader, the writer transitions from the Unlinked state to the Disabled state. When the host disables the stream, the writer transitions to the Disabled state immediately. When the writer or host initiates a flush and disable command, the writer transitions to the Flushing state and then to the Disabled state when the transfer of data in the queue is complete or the command times out, whichever happens first.
You can use the following VIs to disable the stream from the host application:
The following illustration shows the possible states of the writer and the transitions that the writer can control.
The state of the reader matches the state of the stream, except for the Flushing state. Also, the reader cannot control all the transitions between the stream states. When the host links the writer and reader, the reader transitions from the Unlinked state to the Disabled state. The following illustration shows the possible states of the reader and the transitions that the reader can control.