Merge branch 'time_thread_priority' into 'keydbpro'
time thread priority + nanosleep See merge request keydb-dev/KeyDB-Pro!11 Former-commit-id: 423b76a2bbbd568f525f6469ce829ab053972536
This commit is contained in:
commit
ba5b7a6da1
@ -6084,9 +6084,12 @@ void OnTerminate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *timeThreadMain(void*) {
|
void *timeThreadMain(void*) {
|
||||||
|
timespec delay;
|
||||||
|
delay.tv_sec = 0;
|
||||||
|
delay.tv_nsec = 100;
|
||||||
while (true) {
|
while (true) {
|
||||||
updateCachedTime();
|
updateCachedTime();
|
||||||
usleep(1);
|
clock_nanosleep(CLOCK_REALTIME, 0, &delay, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6438,6 +6441,9 @@ int main(int argc, char **argv) {
|
|||||||
serverAssert(cserver.cthreads > 0 && cserver.cthreads <= MAX_EVENT_LOOPS);
|
serverAssert(cserver.cthreads > 0 && cserver.cthreads <= MAX_EVENT_LOOPS);
|
||||||
|
|
||||||
pthread_create(&cserver.time_thread_id, nullptr, timeThreadMain, nullptr);
|
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_t tattr;
|
||||||
pthread_attr_init(&tattr);
|
pthread_attr_init(&tattr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user