aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-11-29 16:14:20 -0500
committerKevin O'Connor <kevin@koconnor.net>2016-11-29 18:49:12 -0500
commit72c4f353e66440896e1aaa1d4b43ca1593bc4634 (patch)
tree2ecfd7596d859dece42f26f9d83cd527cb4dc937
parent4d6830a3730048ded7cb6d50db834e5cef91f14f (diff)
downloadkutter-72c4f353e66440896e1aaa1d4b43ca1593bc4634.tar.gz
kutter-72c4f353e66440896e1aaa1d4b43ca1593bc4634.tar.xz
kutter-72c4f353e66440896e1aaa1d4b43ca1593bc4634.zip
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>
-rw-r--r--klippy/serialqueue.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/klippy/serialqueue.c b/klippy/serialqueue.c
index 444c5ea4..23ed6858 100644
--- a/klippy/serialqueue.c
+++ b/klippy/serialqueue.c
@@ -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
static void
update_receive_seq(struct serialqueue *sq, double eventtime, uint64_t rseq)
@@ -832,6 +841,7 @@ void
serialqueue_exit(struct serialqueue *sq)
{
pollreactor_do_exit(&sq->pr);
+ kick_bg_thread(sq);
int ret = pthread_join(sq->tid, NULL);
if (ret)
report_errno("pthread_join", ret);
@@ -848,15 +858,6 @@ serialqueue_alloc_commandqueue(void)
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
void
serialqueue_send_batch(struct serialqueue *sq, struct command_queue *cq