pdcomm_secs1_poll
Function
Runs line control, timers, and callback I/O for one time slice.
PdcommStatus pdcomm_secs1_poll(PdcommSecs1Endpoint *endpoint, uint64_t now, size_t *attempts)Each call performs up to PdcommSecs1Options::poll_budget steps: it starts the next outbound block when the line is idle, fires expired timers, handles received characters and completed writes, and alternates write and read callback attempts. The callbacks are invoked only from this function. Results are queued as events; drain them with pdcomm_secs1_next_event(). A faulted endpoint performs no work and returns #PDCOMM_OK with zero attempts.
Parameters
| Name | Description |
|---|---|
endpoint | Started endpoint. |
now | Current time in caller ticks, the same unit as the *_ticks options. It must not be smaller than the value passed to the previous call. |
attempts | Receives the number of steps performed (0 first). Must not be NULL. |
Returns
#PDCOMM_OK on success; #PDCOMM_INVALID_ARGUMENT when attempts or endpoint is NULL, or an internal protocol check rejected a step; #PDCOMM_BACKPRESSURE when a staged event must be retrieved first or the event queue is full (the pending step is kept; drain events and poll again); #PDCOMM_INVALID_STATE when the endpoint is not started, or on a wrong-thread, concurrent, or reentrant call; #PDCOMM_LIMIT_EXCEEDED when now is smaller than the previous value or a timer deadline overflows; #PDCOMM_ALLOCATION_FAILED when an internal buffer cannot be allocated; #PDCOMM_POISONED when the endpoint is or becomes poisoned.
Notes
- An I/O failure is not a status: it produces a #PDCOMM_SECS1_EVENT_FAULT event and the call still returns #PDCOMM_OK.
- Thread safety: call only on the creating thread, never from a callback.