serialqueue: Kick the background thread from serialqueue_exit
Wake the background thread up when exiting - as this makes the exit complete faster (and have more predictable timing). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
4d6830a373
commit
72c4f353e6
|
@ -448,6 +448,15 @@ check_wake_receive(struct serialqueue *sq)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write to the internal pipe to wake the background thread if in poll
|
||||||
|
static void
|
||||||
|
kick_bg_thread(struct serialqueue *sq)
|
||||||
|
{
|
||||||
|
int ret = write(sq->pipe_fds[1], ".", 1);
|
||||||
|
if (ret < 0)
|
||||||
|
report_errno("pipe write", ret);
|
||||||
|
}
|
||||||
|
|
||||||
// Update internal state when the receive sequence increases
|
// Update internal state when the receive sequence increases
|
||||||
static void
|
static void
|
||||||
update_receive_seq(struct serialqueue *sq, double eventtime, uint64_t rseq)
|
update_receive_seq(struct serialqueue *sq, double eventtime, uint64_t rseq)
|
||||||
|
@ -832,6 +841,7 @@ void
|
||||||
serialqueue_exit(struct serialqueue *sq)
|
serialqueue_exit(struct serialqueue *sq)
|
||||||
{
|
{
|
||||||
pollreactor_do_exit(&sq->pr);
|
pollreactor_do_exit(&sq->pr);
|
||||||
|
kick_bg_thread(sq);
|
||||||
int ret = pthread_join(sq->tid, NULL);
|
int ret = pthread_join(sq->tid, NULL);
|
||||||
if (ret)
|
if (ret)
|
||||||
report_errno("pthread_join", ret);
|
report_errno("pthread_join", ret);
|
||||||
|
@ -848,15 +858,6 @@ serialqueue_alloc_commandqueue(void)
|
||||||
return cq;
|
return cq;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write to the internal pipe to wake the background thread if in poll
|
|
||||||
static void
|
|
||||||
kick_bg_thread(struct serialqueue *sq)
|
|
||||||
{
|
|
||||||
int ret = write(sq->pipe_fds[1], ".", 1);
|
|
||||||
if (ret < 0)
|
|
||||||
report_errno("pipe write", ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a batch of messages to the given command_queue
|
// Add a batch of messages to the given command_queue
|
||||||
void
|
void
|
||||||
serialqueue_send_batch(struct serialqueue *sq, struct command_queue *cq
|
serialqueue_send_batch(struct serialqueue *sq, struct command_queue *cq
|
||||||
|
|
Loading…
Reference in New Issue