| 45 | } |
| 46 | |
| 47 | JobResult push(JobItem* jobItem, bool isEndJob = false) |
| 48 | { |
| 49 | cond->lock(); |
| 50 | const auto endJobEnqueud = skr_atomic32_load_acquire(&is_end_job_queued); |
| 51 | if (endJobEnqueud && !isEndJob) |
| 52 | { |
| 53 | cond->unlock(); |
| 54 | return ASYNC_RESULT_ERROR_INVALID_STATE; |
| 55 | } |
| 56 | |
| 57 | // update the status of JobItem together with the state of the queue |
| 58 | skr_atomic32_store_release(&jobItem->status, isEndJob ? kJobItemStatusFinishJob : kJobItemStatusWaiting); |
| 59 | list_runnable.emplace_back(jobItem); |
| 60 | |
| 61 | // end job is queued, only end job is accepted |
| 62 | skr_atomic32_store_release(&is_end_job_queued, isEndJob); |
| 63 | |
| 64 | const auto c = skr_atomic32_load_acquire(&waiting_workers_count); |
| 65 | if (c) |
| 66 | { |
| 67 | cond->signal(); |
| 68 | } |
| 69 | |
| 70 | cond->unlock(); |
| 71 | |
| 72 | return ASYNC_RESULT_OK; |
| 73 | } |
| 74 | |
| 75 | void erase(JobItem* jobItem) |
| 76 | { |
no test coverage detected