cwist
Modern C web framework with libttak runtime
Loading...
Searching...
No Matches
async_debug.h
Go to the documentation of this file.
1
/* CWIST_ASYNC_DEBUG, read once (issue #340).
2
*
3
* The reactor and the C1M async path log rare failures when the variable is
4
* set. Those failure paths can fire in bursts, so the flag is cached instead
5
* of calling getenv() each time. The cache is per translation unit; the
6
* first-use race is benign (every thread computes the same value).
7
*
8
* Private to the build; not installed. */
9
#ifndef CWIST_SYS_IO_ASYNC_DEBUG_H
10
#define CWIST_SYS_IO_ASYNC_DEBUG_H
11
12
#include <stdatomic.h>
13
#include <stdbool.h>
14
#include <stdlib.h>
15
16
static
inline
bool
cwist_async_debug_enabled(
void
) {
17
static
_Atomic
int
cached
= -1;
18
int
v
=
atomic_load_explicit
(&
cached
,
memory_order_relaxed
);
19
if
(
v
< 0) {
20
v
=
getenv
(
"CWIST_ASYNC_DEBUG"
) !=
NULL
;
21
atomic_store_explicit
(&
cached
,
v
,
memory_order_relaxed
);
22
}
23
return
v
!= 0;
24
}
25
26
#endif
/* CWIST_SYS_IO_ASYNC_DEBUG_H */
cap
size_t cap
Definition
otel.c:56
src
sys
io
async_debug.h
Generated by
1.9.8