diff options
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c index 6382c01c55..4e2a4fab83 100644 --- a/src/util.c +++ b/src/util.c @@ -5536,6 +5536,15 @@ char *join(const char *x, ...) { return r; } +bool is_main_thread(void) { + static __thread int cached = 0; + + if (_unlikely_(cached == 0)) + cached = getpid() == gettid() ? 1 : -1; + + return cached > 0; +} + static const char *const ioprio_class_table[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime", |