コード例 #1
0
ファイル: Tweaker.cpp プロジェクト: MeteoricGames/pioneer
bool Tweaker::Update()
{
	if(s_isInit && s_enabled) {
		if(s_monitorMode && Pi::player) {
			Body* nt = Pi::player->GetNavTarget();
			Body* ct = Pi::player->GetCombatTarget();
			//Body* target = nt != nullptr ? nt : ct; // Prioritize navtarget over combat target
			Body* target = ct != nullptr ? ct : nt; // Prioritize combattarget since we only care about ships now
			// Check if target changed
			if(target != s_monitorCurrentTarget) {
				// Target changed.
				// Remove active monitor if necessary
				if( s_activeMonitor && target && s_monitorCurrentTarget &&
				    target->GetType() == s_monitorCurrentTarget->GetType()) 
				{
					// Keep the same monitor
				} else {
					// Change monitor
					TwDeleteBar(s_activeMonitor);
					s_activeMonitor = nullptr;
					if(target) { // Only add new monitor if there is a valid target
						s_activeMonitor = CreateMonitor(target);
					}
				}
				s_monitorCurrentTarget = target;
			}
			// Updated monitors
			UpdateMonitor(target);
		}
		return true;
	} else {
		return false;
	}
}
コード例 #2
0
ファイル: netclient.c プロジェクト: ianlater/CS350
int main()
{


  Print("Create lock, create cv, create monitor, start monitor val at 1", 100,"","");
  
  CreateLock("Al",2);
  CreateCondition("Acv", 3);
  monitor = CreateMonitor(0, "test", 4);
  SetMonitor(monitor,0, 1);

}
コード例 #3
0
ファイル: pipe.c プロジェクト: mcavo/so-2015-1c-tp2
Pipe_t *
CreatePipe(const char *name, unsigned size)
{
	char buf[200];
	Pipe_t *p = Malloc(sizeof(Pipe_t));

	p->head = p->tail = p->buf = Malloc(p->size = size);
	p->end = p->buf + size;
	p->monitor = CreateMonitor(name);
	p->name = GetName(p->monitor);
	sprintf(buf, "get %s", name);
	p->cond_get = CreateCondition(buf, p->monitor);
	sprintf(buf, "put %s", name);
	p->cond_put = CreateCondition(buf, p->monitor);

	return p;
}
コード例 #4
0
ファイル: multiClientTest.c プロジェクト: luckyzero0/team7os
int main(){	
	/*routines for testing lock creation and deletion*/
	printf("Beginning multiClient test. For best results, run with -a debug arguments to see server replies.\n",0,0,0,"","");	
	printf("Creating a new lock on the network...\n",0,0,0,"","");	
	lockID = CreateLock("lock",4);
	printf("LockID = [%d]\n",lockID,0,0,"","");	
	
	printf("Creating a new CV on the network...\n",0,0,0,"","");
	cvID = CreateCondition("CV",2);
	printf("CVID = [%d]\n",cvID,0,0,"","");
	
	
	printf("Creating a new MV on the network...\n",0,0,0,"","");
	mvID = CreateMonitor("MV",2);
	printf("MVID = [%d]\n",mvID,0,0,"","");
	
	printf("Acquiring Lock[%d].\n",lockID,0,0,"","");
	Acquire(lockID);	
	printf("Lock[%d] acquired.\n",lockID,0,0,"","");
		
	printf("Modifying MV[%d].\n",mvID,0,0,"","");
	for (x = 0; x < 20; x++)
	{
		SetMonitor(mvID,x);
	}
	printf("Done modifying. MV[%d] = [%d]\n",mvID,GetMonitor(mvID),0,"","");
	
	
	printf("Signalling CVID[%d].\n",cvID,0,0,"","");
	Signal(cvID,lockID);
	printf("CVID[%d] signaled.\n",cvID,0,0,"","");
	
	
	
	printf("Releasing LockID[%d].\n",lockID,0,0,"","");
	Release(lockID);
	printf("LockID[%d] released",lockID,0,0,"","");		
		
		
	printf("Done.\n",0,0,0,"","");
	
	Exit(0);
}
コード例 #5
0
ファイル: berryJobManager.cpp プロジェクト: 151706061/MITK
Job::Pointer JobManager::StartJob()
{
  Job::Pointer job(nullptr);
  while (true)
  {
    job = NextJob();
    if (!job)
    return Job::Pointer(nullptr);
    //must perform this outside sync block because it is third party code
    bool shouldRun = job->ShouldRun();
    //check for listener veto
    if (shouldRun)
    m_JobListeners.AboutToRun(job);
    //listeners may have canceled or put the job to sleep
    bool endJob = false;
    {
      Poco::ScopedLock<Poco::Mutex> lock(m_mutex);
      InternalJob::Pointer internal = job;
      if (internal->InternalGetState() == InternalJob::ABOUT_TO_RUN)
      {
        if (shouldRun && !internal->IsAboutToRunCanceled())
        {
          internal->SetProgressMonitor(CreateMonitor(job));
          //change from ABOUT_TO_RUN to RUNNING
          internal->InternalSetState(Job::RUNNING);
          break;
        }
        internal->SetAboutToRunCanceled(false);
        endJob = true;
        //fall through and end the job below
      }
    }
    if (endJob)
    {
      //job has been vetoed or canceled, so mark it as done
      EndJob(job,Status::CANCEL_STATUS(BERRY_STATUS_LOC), true);
      continue;
    }
  }
  m_JobListeners.Running(job);
  return job;
}
コード例 #6
0
ファイル: pmon.c プロジェクト: joseignaciosg/tpeSO2
int 
main(void)
{
	mon = CreateMonitor("dos");
	cond = CreateCondition("key", mon);

	Ready(CreateTask(consumer, 2000, "consumer", "consumer", DEFAULT_PRIO));

	while ( true )
	{
		EnterMonitor(mon);
		while ( key )
			WaitCondition(cond);
		key = getch();
		if ( key == 'S' || key == 's' )
			return 0;
		SignalCondition(cond);
		LeaveMonitor(mon);
	}
}