simulatorCore/src/scheduler.h
//!< @brief Global function for triggering scheduler deletion (Takes a bit of synchronisation, see Scheduler::terminate)
< @brief Global function for triggering scheduler deletion (Takes a bit of synchronisation, see Scheduler::terminate)
< @brief Global function for triggering scheduler deletion ( Takes a bit of synchronisation see Scheduler :: terminate )
static void deleteScheduler() {
		if (scheduler != NULL) {
			delMutex.lock();
			if (scheduler != NULL) {
				if (!scheduler->terminate.load()) {
					scheduler->terminate.store(true);
					if (scheduler->state == NOTSTARTED) {
						scheduler->state = ENDED;
						scheduler->start(SCHEDULER_MODE_FASTEST);
					}
					scheduler->schedulerThread->join();
				}
				delete scheduler;
				scheduler = NULL;
			}
			delMutex.unlock();
		}
	}
static void deleteScheduler ( ) { if ( scheduler != NULL ) { delMutex . lock ( ) ; if ( scheduler != NULL ) { if ( ! scheduler -> terminate . load ( ) ) { scheduler -> terminate . store ( true ) ; if ( scheduler -> state == NOTSTARTED ) { scheduler -> state = ENDED ; scheduler -> start ( SCHEDULER_MODE_FASTEST ) ; } scheduler -> schedulerThread -> join ( ) ; } delete scheduler ; scheduler = NULL ; } delMutex . unlock ( ) ; } }
< @brief Global function for triggering scheduler deletion (Takes a bit of synchronisation, see Scheduler::terminate)
< @brief Global function for triggering scheduler deletion ( Takes a bit of synchronisation see Scheduler :: terminate )
// Ensure Scheduler has not been deleted yet // Take the deletion lock // Ensure again that it has not been deleted meanwhile // If scheduler is not yet in termination mode (means it is still running), instruct it to terminate // In case scheduler thread if waiting on semaphore before start, release it // Wait until scheduler termination // Scheduler can now be safely deleted // Release lock, even though another thread was waiting, double deletion cannot occur