ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
flow_control.h File Reference

Go to the source code of this file.

Data Structures

struct  flow_control_debounce_t

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 20 of file flow_control.c.

20 {
21 if (!debounce)
22 return;
23 debounce->pending = false;
24 debounce->due_ns = 0;
25}

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 12 of file flow_control.c.

13 {
14 if (!debounce || !debounce->pending || now_ns < debounce->due_ns)
15 return false;
16 debounce->pending = false;
17 return true;
18}

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.

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

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

Referenced by log_search_handle_key(), and log_search_insert_text().