RTE RBC 2oo2 Reference Application 0.1.0 build 0006685
SIL 4 2oo2 Dual-Site Fault-Tolerant ERTMS Radio Block Centre Reference Architecture
Loading...
Searching...
No Matches
ab_gp_util_link_gate.c File Reference

See ab_gp_util_link_gate.h. More...

Include dependency graph for ab_gp_util_link_gate.c:

Go to the source code of this file.

Functions

void ab_gp_util_link_gate_init (ab_gp_util_link_gate_t *gate)
 Resets the gate: never opened, first attempt allowed at any time.
bool ab_gp_util_link_gate_is_open (const ab_gp_util_link_gate_t *gate)
 Whether an open attempt has succeeded (the link is open for good).
bool ab_gp_util_link_gate_may_attempt (const ab_gp_util_link_gate_t *gate, rte_timestamp_ms_t now_ms)
 Whether a send (and with it, before the first success, an open attempt) may run now.
void ab_gp_util_link_gate_on_attempt (ab_gp_util_link_gate_t *gate, rte_timestamp_ms_t now_ms)
 Records that an open attempt starts now (call right before the send that triggers the open).
void ab_gp_util_link_gate_on_result (ab_gp_util_link_gate_t *gate, rte_status_t status, rte_timestamp_ms_t now_ms)
 Feeds back the result of a send that ran under the gate.

Detailed Description

Function Documentation

◆ ab_gp_util_link_gate_init()

void ab_gp_util_link_gate_init ( ab_gp_util_link_gate_t * gate)

Resets the gate: never opened, first attempt allowed at any time.

Parameters
gategate to reset; ignored when NULL

Definition at line 9 of file ab_gp_util_link_gate.c.

◆ ab_gp_util_link_gate_is_open()

bool ab_gp_util_link_gate_is_open ( const ab_gp_util_link_gate_t * gate)

Whether an open attempt has succeeded (the link is open for good).

Parameters
gategate to query
Returns
true once ab_gp_util_link_gate_on_result() saw RTE_STATUS_OK; false before that or when gate is NULL

Definition at line 18 of file ab_gp_util_link_gate.c.

◆ ab_gp_util_link_gate_may_attempt()

bool ab_gp_util_link_gate_may_attempt ( const ab_gp_util_link_gate_t * gate,
rte_timestamp_ms_t now_ms )

Whether a send (and with it, before the first success, an open attempt) may run now.

Parameters
gategate to query
now_mscurrent monotonic time
Returns
true when the link is open, or when now_ms has reached the next allowed attempt time; false otherwise and when gate is NULL

Definition at line 29 of file ab_gp_util_link_gate.c.

◆ ab_gp_util_link_gate_on_attempt()

void ab_gp_util_link_gate_on_attempt ( ab_gp_util_link_gate_t * gate,
rte_timestamp_ms_t now_ms )

Records that an open attempt starts now (call right before the send that triggers the open).

Before the first success this reserves the back-off interval at once, so a nested call during the attempt (the open itself logs INFO lines, which the JRU forwarder republishes over this same link) is refused instead of starting a second attempt. No effect once the link is open.

Parameters
gategate to update; ignored when NULL
now_mscurrent monotonic time

Definition at line 40 of file ab_gp_util_link_gate.c.

◆ ab_gp_util_link_gate_on_result()

void ab_gp_util_link_gate_on_result ( ab_gp_util_link_gate_t * gate,
rte_status_t status,
rte_timestamp_ms_t now_ms )

Feeds back the result of a send that ran under the gate.

RTE_STATUS_OK marks the link open for good. Any other status before the first success refuses further attempts until now_ms + RTE_EXAMPLE_UTIL_REOPEN_BACKOFF_MS. A failure after the first success changes nothing (the link stays open in the channel service and a send on it does not block).

Parameters
gategate to update; ignored when NULL
statusresult of the send
now_mscurrent monotonic time (after the attempt)

Definition at line 48 of file ab_gp_util_link_gate.c.