Success running on linux
This commit is contained in:
@@ -14,7 +14,11 @@ void PushWork(WorkQueue *wq, void *data, WorkQueueCallback *callback) {
|
||||
entry->data = data;
|
||||
entry->callback = callback;
|
||||
|
||||
wq->completion_goal += 1;
|
||||
wq->completion_goal += 1;dex_to_read + 1) % Lengthof(wq->entries);
|
||||
if (original_index_to_read != wq->index_to_write) {
|
||||
int64_t index = AtomicCompareAndSwap(&wq->index_to_read, new_index_to_read, original_index_to_read);
|
||||
if (index == original_index_to_read) {
|
||||
WorkQueueEntry *entry = wq->entries +
|
||||
_WriteBarrier();
|
||||
wq->index_to_write = new_index;
|
||||
ReleaseSemaphore(wq->semaphore, 1, 0);
|
||||
@@ -23,11 +27,7 @@ void PushWork(WorkQueue *wq, void *data, WorkQueueCallback *callback) {
|
||||
bool TryDoingWork(WorkQueue *wq) {
|
||||
bool should_sleep = false;
|
||||
int64_t original_index_to_read = wq->index_to_read;
|
||||
int64_t new_index_to_read = (original_index_to_read + 1) % Lengthof(wq->entries);
|
||||
if (original_index_to_read != wq->index_to_write) {
|
||||
int64_t index = AtomicCompareAndSwap(&wq->index_to_read, new_index_to_read, original_index_to_read);
|
||||
if (index == original_index_to_read) {
|
||||
WorkQueueEntry *entry = wq->entries + index;
|
||||
int64_t new_index_to_read = (original_inindex;
|
||||
entry->callback(entry->data);
|
||||
AtomicIncrement(&wq->completion_index);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user