================================================================================================
| 189 | |
| 190 | // ================================================================================================ |
| 191 | bool Event::setCallback(int32_t status, Event::CallBackFunction callback, void* data, |
| 192 | bool blocking) { |
| 193 | assert(status >= CL_COMPLETE && status <= CL_QUEUED && "Invalid status"); |
| 194 | |
| 195 | CallBackEntry* entry = new CallBackEntry(status, callback, data, blocking); |
| 196 | if (entry == NULL) { |
| 197 | return false; |
| 198 | } |
| 199 | |
| 200 | entry->next_ = callbacks_; |
| 201 | while (!callbacks_.compare_exchange_weak( |
| 202 | entry->next_, entry)); // Someone else is also updating the head of the linked list! reload. |
| 203 | |
| 204 | // Check if the event has already reached 'status' |
| 205 | if (this->status() <= status && entry->callback_ != CallBackFunction(0)) { |
| 206 | if (entry->callback_.exchange(NULL) != NULL) { |
| 207 | callback(as_cl(this), status, entry->data_); |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | return true; |
| 212 | } |
| 213 | |
| 214 | // ================================================================================================ |
| 215 | void Event::processCallbacks(int32_t status) const { |
no test coverage detected