Skip to content

Commit

Permalink
Remove windup behavior from break_dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Thompson authored and geky committed Aug 4, 2019
1 parent c4e8a61 commit 1acddeb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions equeue.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int equeue_create_inplace(equeue_t *q, size_t size, void *buffer) {
q->queue = 0;
q->tick = equeue_tick();
q->generation = 0;
q->breaks = 0;
q->break_requested = false;

q->background.active = false;
q->background.update = 0;
Expand Down Expand Up @@ -355,7 +355,7 @@ void equeue_cancel(equeue_t *q, int id) {

void equeue_break(equeue_t *q) {
equeue_mutex_lock(&q->queuelock);
q->breaks++;
q->break_requested = true;
equeue_mutex_unlock(&q->queuelock);
equeue_sema_signal(&q->eventsema);
}
Expand Down Expand Up @@ -425,10 +425,10 @@ void equeue_dispatch(equeue_t *q, int ms) {
equeue_sema_wait(&q->eventsema, deadline);

// check if we were notified to break out of dispatch
if (q->breaks) {
if (q->break_requested) {
equeue_mutex_lock(&q->queuelock);
if (q->breaks > 0) {
q->breaks--;
if (q->break_requested) {
q->break_requested = false;
equeue_mutex_unlock(&q->queuelock);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion equeue.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct equeue_event {
typedef struct equeue {
struct equeue_event *queue;
unsigned tick;
unsigned breaks;
bool break_requested;
uint8_t generation;

unsigned char *buffer;
Expand Down

0 comments on commit 1acddeb

Please sign in to comment.