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

Shared deadline and scheduling helpers for diagnostic reports. More...

Go to the source code of this file.

Functions

uint64_t debug_report_deadline_after (uint64_t now, uint64_t delay_ns)
void debug_report_schedule (mutex_t *mutex, cond_t *condition, uint64_t *deadline, uint64_t delay_ns)

Detailed Description

Shared deadline and scheduling helpers for diagnostic reports.

Definition in file debug_helpers.h.

Function Documentation

◆ debug_report_deadline_after()

uint64_t debug_report_deadline_after ( uint64_t now,
uint64_t delay_ns )

Compute a monotonic deadline, saturating on overflow.

Definition at line 4 of file debug_helpers.c.

4 {
5 return delay_ns > UINT64_MAX - now ? UINT64_MAX : now + delay_ns;
6}

Referenced by debug_report_schedule(), debug_stats_poll(), and debug_stats_set_memory_report_interval().

◆ debug_report_schedule()

void debug_report_schedule ( mutex_t * mutex,
cond_t * condition,
uint64_t * deadline,
uint64_t delay_ns )

Schedule a report under the initialized worker mutex and wake its condition. Duplicate requests for the same report retain the earliest deadline.

Definition at line 8 of file debug_helpers.c.

8 {
9 uint64_t requested = debug_report_deadline_after(time_get_ns(), delay_ns);
10 mutex_lock(mutex);
11 if (!*deadline || requested < *deadline)
12 *deadline = requested;
13 cond_signal(condition);
14 mutex_unlock(mutex);
15}
uint64_t debug_report_deadline_after(uint64_t now, uint64_t delay_ns)
unsigned long long uint64_t
Definition common.h:63

References debug_report_deadline_after().

Referenced by debug_errno_print_delayed().