ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
flow_control.c File Reference

Go to the source code of this file.

Functions

void flow_control_debounce_trigger (flow_control_debounce_t *debounce, uint64_t now_ns, uint64_t delay_ns)
bool flow_control_debounce_take_ready (flow_control_debounce_t *debounce, uint64_t now_ns)
void flow_control_debounce_cancel (flow_control_debounce_t *debounce)

Function Documentation

◆ flow_control_debounce_cancel()

void flow_control_debounce_cancel ( flow_control_debounce_t * debounce)

Discard a pending action.

Definition at line 17 of file flow_control.c.

17 {
18 if (!debounce)
19 return;
20 debounce->pending = false;
21 debounce->due_ns = 0;
22}

References flow_control_debounce_t::due_ns, and flow_control_debounce_t::pending.

Referenced by log_search_enter_mode(), and log_search_exit_mode().

◆ flow_control_debounce_take_ready()

bool flow_control_debounce_take_ready ( flow_control_debounce_t * debounce,
uint64_t now_ns )

Consume a pending action once its quiet period has elapsed.

Definition at line 10 of file flow_control.c.

10 {
11 if (!debounce || !debounce->pending || now_ns < debounce->due_ns)
12 return false;
13 debounce->pending = false;
14 return true;
15}

References flow_control_debounce_t::pending.

Referenced by log_search_process_pending().

◆ flow_control_debounce_trigger()

void flow_control_debounce_trigger ( flow_control_debounce_t * debounce,
uint64_t now_ns,
uint64_t delay_ns )

Record an event whose action should run after delay_ns of inactivity.

Definition at line 3 of file flow_control.c.

3 {
4 if (!debounce)
5 return;
6 debounce->due_ns = UINT64_MAX - now_ns < delay_ns ? UINT64_MAX : now_ns + delay_ns;
7 debounce->pending = true;
8}

References flow_control_debounce_t::due_ns, and flow_control_debounce_t::pending.

Referenced by log_search_handle_key(), and log_search_insert_text().