projects
/
buftee
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
4b7c0d6
)
Reduce locking in writer_routine().
author
Emil Mikulic
<emikulic@gmail.com>
Sun, 10 Mar 2013 16:45:24 +0000
(
03:45
+1100)
committer
Emil Mikulic
<emikulic@gmail.com>
Sun, 10 Mar 2013 17:26:24 +0000
(
04:26
+1100)
buftee.c
patch
|
blob
|
history
diff --git
a/buftee.c
b/buftee.c
index
c31ba69
..
23d2d2c
100644
(file)
--- a/
buftee.c
+++ b/
buftee.c
@@
-276,11
+276,9
@@
static void unlock(pthread_mutex_t* mutex) {
static void* writer_routine(void *arg) {
struct writer_thread* my = arg;
static void* writer_routine(void *arg) {
struct writer_thread* my = arg;
+ struct buf* buf = NULL;
+ lock(&shared_queue_mutex);
for (;;) {
for (;;) {
- // FIXME: less locking
- struct buf* buf = NULL;
-
- lock(&shared_queue_mutex);
while (!stopping && STAILQ_EMPTY(&my->queue)) {
// Sleep.
pthread_cond_wait(&shared_wakeup_cond, &shared_queue_mutex);
while (!stopping && STAILQ_EMPTY(&my->queue)) {
// Sleep.
pthread_cond_wait(&shared_wakeup_cond, &shared_queue_mutex);
@@
-302,7
+300,6
@@
static void* writer_routine(void *arg) {
// Unreference buffer, freeing it if we have to.
lock(&shared_queue_mutex);
unref_buf(buf);
// Unreference buffer, freeing it if we have to.
lock(&shared_queue_mutex);
unref_buf(buf);
- unlock(&shared_queue_mutex);
}
warnx("thread exiting cleanly");
return NULL;
}
warnx("thread exiting cleanly");
return NULL;