time thread priority + nanosleep
Former-commit-id: c84f296edabc001a1836ab8437f746dcff811148
This commit is contained in:
parent
877ad1e4b2
commit
175b266c34
@ -6068,9 +6068,12 @@ void OnTerminate()
|
||||
}
|
||||
|
||||
void *timeThreadMain(void*) {
|
||||
timespec delay;
|
||||
delay.tv_sec = 0;
|
||||
delay.tv_nsec = 100;
|
||||
while (true) {
|
||||
updateCachedTime();
|
||||
usleep(1);
|
||||
clock_nanosleep(CLOCK_REALTIME, 0, &delay, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6422,6 +6425,9 @@ int main(int argc, char **argv) {
|
||||
serverAssert(cserver.cthreads > 0 && cserver.cthreads <= MAX_EVENT_LOOPS);
|
||||
|
||||
pthread_create(&cserver.time_thread_id, nullptr, timeThreadMain, nullptr);
|
||||
struct sched_param time_thread_priority;
|
||||
time_thread_priority.sched_priority = sched_get_priority_max(SCHED_FIFO);
|
||||
pthread_setschedparam(cserver.time_thread_id, SCHED_FIFO, &time_thread_priority);
|
||||
|
||||
pthread_attr_t tattr;
|
||||
pthread_attr_init(&tattr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user