Commit c2e3dd07 authored by Scott Vokes's avatar Scott Vokes
Browse files

Don't memset tasks during cleanup - can break assertion for commit marks.

Also, don't notify dormant thread(s) that a task is available until after
the commit operation has finished. This should slightly improve throughput.
parent e261327a
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -118,11 +118,9 @@ bool threadpool_schedule(struct threadpool *t, struct threadpool_task *task,
            tbuf->cleanup = task->cleanup;
            tbuf->udata = task->udata;

            commit_current_task(t, tbuf, wh);
            notify_new_task(t);
            if (pushback) { *pushback = wh - rh; }

            commit_current_task(t, tbuf, wh);
            //printf("delta %zd\n", wh);
            return true;
        }
    }
@@ -184,7 +182,7 @@ bool threadpool_shutdown(struct threadpool *t, bool kill_all) {
        if (ATOMIC_BOOL_COMPARE_AND_SWAP(&t->task_request_head, rh, rh + 1)) {
            if (tbuf->cleanup) {
                tbuf->cleanup(tbuf->udata);
                memset(tbuf, 0, sizeof(*tbuf));
                tbuf->udata = NULL;
            }
            SPIN_ADJ(t->task_release_head, 1);
        }