mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-12 13:58:58 -04:00
Add EVENT_PRECISE_TIMER environment var for selecting precise-but-slow timer
This commit is contained in:
parent
f5e4eb05e5
commit
a2598ec6bd
15
event.c
15
event.c
@ -559,10 +559,18 @@ event_base_new_with_config(const struct event_config *cfg)
|
||||
event_warn("%s: calloc", __func__);
|
||||
return NULL;
|
||||
}
|
||||
evutil_configure_monotonic_time_(&base->monotonic_timer,
|
||||
cfg && (cfg->flags & EVENT_BASE_FLAG_PRECISE_TIMER));
|
||||
|
||||
should_check_environment =
|
||||
!(cfg && (cfg->flags & EVENT_BASE_FLAG_IGNORE_ENV));
|
||||
|
||||
{
|
||||
struct timeval tmp;
|
||||
int precise_time =
|
||||
cfg && (cfg->flags & EVENT_BASE_FLAG_PRECISE_TIMER);
|
||||
if (should_check_environment && !precise_time)
|
||||
precise_time = evutil_getenv_("EVENT_PRECISE_TIMER") != NULL;
|
||||
evutil_configure_monotonic_time_(&base->monotonic_timer, precise_time);
|
||||
|
||||
gettime(base, &tmp);
|
||||
}
|
||||
|
||||
@ -586,9 +594,6 @@ event_base_new_with_config(const struct event_config *cfg)
|
||||
|
||||
base->evbase = NULL;
|
||||
|
||||
should_check_environment =
|
||||
!(cfg && (cfg->flags & EVENT_BASE_FLAG_IGNORE_ENV));
|
||||
|
||||
if (cfg) {
|
||||
memcpy(&base->max_dispatch_time,
|
||||
&cfg->max_dispatch_interval, sizeof(struct timeval));
|
||||
|
Loading…
x
Reference in New Issue
Block a user