mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-13 06:16:10 -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__);
|
event_warn("%s: calloc", __func__);
|
||||||
return NULL;
|
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;
|
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);
|
gettime(base, &tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,9 +594,6 @@ event_base_new_with_config(const struct event_config *cfg)
|
|||||||
|
|
||||||
base->evbase = NULL;
|
base->evbase = NULL;
|
||||||
|
|
||||||
should_check_environment =
|
|
||||||
!(cfg && (cfg->flags & EVENT_BASE_FLAG_IGNORE_ENV));
|
|
||||||
|
|
||||||
if (cfg) {
|
if (cfg) {
|
||||||
memcpy(&base->max_dispatch_time,
|
memcpy(&base->max_dispatch_time,
|
||||||
&cfg->max_dispatch_interval, sizeof(struct timeval));
|
&cfg->max_dispatch_interval, sizeof(struct timeval));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user