util: add is_main_thread() call
This commit is contained in:
parent
cd0ed1db9b
commit
b636465bc0
|
@ -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",
|
||||
|
|
|
@ -460,6 +460,8 @@ int get_files_in_directory(const char *path, char ***list);
|
|||
|
||||
char *join(const char *x, ...) _sentinel_;
|
||||
|
||||
bool is_main_thread(void);
|
||||
|
||||
#define NULSTR_FOREACH(i, l) \
|
||||
for ((i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)
|
||||
|
||||
|
|
Loading…
Reference in New Issue