Loading src/lib/bus/sender.c +2 −2 Original line number Diff line number Diff line Loading @@ -36,8 +36,8 @@ #include "yacht.h" #include "sender_internal.h" #define MIN_DELAY 100 #define INFINITE_DELAY -1 #define MIN_DELAY 100 /* msec */ #define INFINITE_DELAY -1 /* poll will only return upon an event */ /* Offset for s->fds[0], which is the command pipe. */ #define CMD_FD (1) Loading src/lib/threadpool/threadpool.c +5 −16 Original line number Diff line number Diff line Loading @@ -28,14 +28,12 @@ #include "threadpool_internals.h" #define MIN_DELAY 2 #define MIN_DELAY 10 /* msec */ #define DEFAULT_MAX_DELAY 10000 /* msec */ #define INFINITE_DELAY -1 #define INFINITE_DELAY -1 /* poll will only return upon an event */ #define DEFAULT_TASK_RINGBUF_SIZE2 8 #define DEFAULT_MAX_THREADS 8 #define DORMANT_WHEN_IDLE false static void set_defaults(struct threadpool_config *cfg) { if (cfg->task_ringbuf_size2 == 0) { cfg->task_ringbuf_size2 = DEFAULT_TASK_RINGBUF_SIZE2; Loading Loading @@ -293,18 +291,13 @@ static void *thread_task(void *arg) { size_t mask = t->task_ringbuf_mask; struct pollfd pfd[1] = { { .fd=ti->child_fd, .events=POLLIN }, }; uint8_t read_buf[NOTIFY_MSG_LEN]; #if DORMANT_WHEN_IDLE const size_t delay = 1000; #else int delay = MIN_DELAY; #endif const size_t delay = MIN_DELAY; while (ti->status < STATUS_SHUTDOWN) { if (t->task_request_head == t->task_commit_head) { #if !DORMANT_WHEN_IDLE if (ti->status == STATUS_AWAKE) { if (delay == INFINITE_DELAY || delay > 1) { ti->status = STATUS_ASLEEP; } if (delay > MIN_DELAY) { ti->status = STATUS_ASLEEP; } } else { if (delay == 0) { delay = MIN_DELAY; Loading @@ -312,11 +305,9 @@ static void *thread_task(void *arg) { delay <<= 1; } if ((size_t)delay > t->max_delay) { // delay = t->max_delay; delay = INFINITE_DELAY; } } #endif int res = poll(pfd, 1, delay); if (res == 1) { Loading @@ -327,9 +318,7 @@ static void *thread_task(void *arg) { break; } else if (pfd[0].revents & POLLIN) { if (ti->status == STATUS_ASLEEP) { ti->status = STATUS_AWAKE; } #if !DORMANT_WHEN_IDLE delay = MIN_DELAY; #endif //SPIN_ADJ(t->active_threads, 1); ssize_t rres = read(ti->child_fd, read_buf, NOTIFY_MSG_LEN); if (rres < 0) { Loading Loading
src/lib/bus/sender.c +2 −2 Original line number Diff line number Diff line Loading @@ -36,8 +36,8 @@ #include "yacht.h" #include "sender_internal.h" #define MIN_DELAY 100 #define INFINITE_DELAY -1 #define MIN_DELAY 100 /* msec */ #define INFINITE_DELAY -1 /* poll will only return upon an event */ /* Offset for s->fds[0], which is the command pipe. */ #define CMD_FD (1) Loading
src/lib/threadpool/threadpool.c +5 −16 Original line number Diff line number Diff line Loading @@ -28,14 +28,12 @@ #include "threadpool_internals.h" #define MIN_DELAY 2 #define MIN_DELAY 10 /* msec */ #define DEFAULT_MAX_DELAY 10000 /* msec */ #define INFINITE_DELAY -1 #define INFINITE_DELAY -1 /* poll will only return upon an event */ #define DEFAULT_TASK_RINGBUF_SIZE2 8 #define DEFAULT_MAX_THREADS 8 #define DORMANT_WHEN_IDLE false static void set_defaults(struct threadpool_config *cfg) { if (cfg->task_ringbuf_size2 == 0) { cfg->task_ringbuf_size2 = DEFAULT_TASK_RINGBUF_SIZE2; Loading Loading @@ -293,18 +291,13 @@ static void *thread_task(void *arg) { size_t mask = t->task_ringbuf_mask; struct pollfd pfd[1] = { { .fd=ti->child_fd, .events=POLLIN }, }; uint8_t read_buf[NOTIFY_MSG_LEN]; #if DORMANT_WHEN_IDLE const size_t delay = 1000; #else int delay = MIN_DELAY; #endif const size_t delay = MIN_DELAY; while (ti->status < STATUS_SHUTDOWN) { if (t->task_request_head == t->task_commit_head) { #if !DORMANT_WHEN_IDLE if (ti->status == STATUS_AWAKE) { if (delay == INFINITE_DELAY || delay > 1) { ti->status = STATUS_ASLEEP; } if (delay > MIN_DELAY) { ti->status = STATUS_ASLEEP; } } else { if (delay == 0) { delay = MIN_DELAY; Loading @@ -312,11 +305,9 @@ static void *thread_task(void *arg) { delay <<= 1; } if ((size_t)delay > t->max_delay) { // delay = t->max_delay; delay = INFINITE_DELAY; } } #endif int res = poll(pfd, 1, delay); if (res == 1) { Loading @@ -327,9 +318,7 @@ static void *thread_task(void *arg) { break; } else if (pfd[0].revents & POLLIN) { if (ti->status == STATUS_ASLEEP) { ti->status = STATUS_AWAKE; } #if !DORMANT_WHEN_IDLE delay = MIN_DELAY; #endif //SPIN_ADJ(t->active_threads, 1); ssize_t rres = read(ti->child_fd, read_buf, NOTIFY_MSG_LEN); if (rres < 0) { Loading