Beispiel #1
0
void System2Extension::AppendCallback(std::shared_ptr<Callback> callback) {
    // Lock mutex to gain thread safety
    while (!this->threadMutex->TryLock()) {
        sleep_ms(1);
    }

    if (this->isRunning) {
        // Add the callback to the queue and unlock mutex again
        this->callbackQueue.push_back(callback);
    } else {
        // Abort the callback if we not running anymore
        callback->Abort();
    }

    this->threadMutex->Unlock();
}