示例#1
0
 virtual bool configure(ResourceFinder &rf)
 {
     Time::turboBoost();
     
     thr=new ProcessThread(rf);
     if (thr->start())
         return true;
     else
     {
         delete thr;    
         return false;
     }
 }
示例#2
0
int StopThreads()
{
  servercfg->accept_clients = 0;
  servercfg->echo_loop = 0;

  unsigned num_threads = 0;
  gxString message;
  ProcessThread t;
  int error_level = 0;

  // If client or non-interactive command stop the console thread
  if(servercfg->console_thread) { 
    LogProcMessage("Stopping CM console_thread");
    if(servercfg->console_thread->GetThreadState() == gxTHREAD_STATE_RUNNING) {
      t.CancelThread(servercfg->console_thread);
      sSleep(1); // Allow I/O recovery time
      t.JoinThread(servercfg->console_thread);
      if(servercfg->console_thread->GetThreadState() == gxTHREAD_STATE_CANCELED) {
	LogProcMessage("CM console_thread was halted");
      }
      else {
	LogProcMessage("CM console_thread did not shutdown properly");
	error_level = 1;
      }
    }
    else {
      LogProcMessage("CM console_thread was stopped");
    }
    if(error_level == 0) {
      delete servercfg->console_thread;
      servercfg->console_thread = 0;
    }
  }
  else {
    LogProcMessage("CM console_thread not active");
  }

  // Stop the CM crons first
  if(servercfg->crontab_thread) { 
    LogProcMessage("Stopping CM crontab_thread");
    if(servercfg->crontab_thread->GetThreadState() == gxTHREAD_STATE_RUNNING) {
      t.CancelThread(servercfg->crontab_thread);
      sSleep(1); // Allow I/O recovery time
      t.JoinThread(servercfg->crontab_thread);
      if(servercfg->crontab_thread->GetThreadState() == gxTHREAD_STATE_CANCELED) {
	LogProcMessage("CM crontab_thread was halted");
      }
      else {
	LogProcMessage("CM crontab_thread did not shutdown properly");
	error_level = 1;
      }
    }
    else {
      LogProcMessage("CM crontab_thread was stopped");
    }
    if(error_level == 0) {
      delete servercfg->crontab_thread;
      servercfg->crontab_thread = 0;
    }
  }
  else {
    LogProcMessage("CM crontab_thread not active");
  }

  // Release all floating IP addresses
  if(servercfg->ipaddr_thread) { 
    LogProcMessage("Stopping CM ipaddr_thread");
    if(servercfg->ipaddr_thread->GetThreadState() == gxTHREAD_STATE_RUNNING) {
      t.CancelThread(servercfg->ipaddr_thread);
      sSleep(1); // Allow I/O recovery time
      t.JoinThread(servercfg->ipaddr_thread);
      if(servercfg->ipaddr_thread->GetThreadState() == gxTHREAD_STATE_CANCELED) {
	LogProcMessage("CM ipaddr_thread was halted");
      }
      else {
	LogProcMessage("CM ipaddr_thread did not shutdown properly");
	error_level = 1;
      }
    }
    else {
      LogProcMessage("CM ipaddr_thread was stopped");
    }
    if(error_level == 0) {
      delete servercfg->ipaddr_thread;
      servercfg->ipaddr_thread = 0;
    }
  }
  else {
    LogProcMessage("CM ipaddr_thread not active");
  }

  // The the other nodes to take over
  if(servercfg->keep_alive_thread) { 
    LogProcMessage("Stopping CM UDP keep alive thread");
    if(servercfg->keep_alive_thread->GetThreadState() == gxTHREAD_STATE_RUNNING) {
      t.CancelThread(servercfg->keep_alive_thread);
      sSleep(1); // Allow I/O recovery time
      t.JoinThread(servercfg->keep_alive_thread);
      if(servercfg->keep_alive_thread->GetThreadState() == gxTHREAD_STATE_CANCELED) {
	LogProcMessage("CM UDP keep alive thread was halted");
      }
      else {
	LogProcMessage("CM UDP keep alive thread did not shutdown properly");
	error_level = 1;
      }
    }
    else {
      LogProcMessage("CM UDP keep alive thread was stopped");
    }
    if(error_level == 0) {
      delete servercfg->keep_alive_thread;
      servercfg->keep_alive_thread = 0;
    }
  }
  else {
    LogProcMessage("CM UDP keep alive thread not active");
  }

  if(servercfg->udp_server_thread) { 
    LogProcMessage("Stopping CM UDP server thread");
    if(servercfg->udp_server_thread->GetThreadState() == gxTHREAD_STATE_RUNNING) {
      t.CancelThread(servercfg->udp_server_thread);
      sSleep(1); // Allow I/O recovery time
      t.JoinThread(servercfg->udp_server_thread);
      if(servercfg->udp_server_thread->GetThreadState() == gxTHREAD_STATE_CANCELED) {
	LogProcMessage("CM UDP server thread was halted");
      }
      else {
	LogProcMessage("CM UDP server thread did not shutdown properly");
	error_level = 1;
      }
    }
    else {
      LogProcMessage("CM UDP server thread was stopped");
    }
    if(error_level == 0) {
      delete servercfg->udp_server_thread;
      servercfg->udp_server_thread = 0;
    }
  }
  else {
    LogProcMessage("CM UDP server thread not active");
  }

  if(servercfg->client_request_pool ) {
    if(!servercfg->client_request_pool->IsEmpty()) {
      LogProcMessage("Closing all open TCP client threads");
      thrPoolNode *ptr = servercfg->client_request_pool->GetHead();
      while(ptr) {
	gxThread_t *thread = ptr->GetThreadPtr();
	if(thread->GetThreadState() == gxTHREAD_STATE_RUNNING) {
	  num_threads++;
	  t.CancelThread(thread);
	  LogProcMessage("Shutting down TCP client thread");
	  t.JoinThread(thread);
	  if(thread->GetThreadState() == gxTHREAD_STATE_CANCELED) {
	    LogProcMessage("Client TCP thread was canceled");
	  }
	  else {
	    LogProcMessage("Client TCP thread was not canceled");
	    error_level = 1;
	  }
	}
	ptr = ptr->GetNext();
      } 
      message << clear << "Found " << num_threads << " working TCP client threads";
      LogProcMessage(message.c_str());
      if(error_level == 0) {
	t.DestroyThreadPool(servercfg->client_request_pool);
	servercfg->client_request_pool = 0;
      }
    }
    else {
      LogProcMessage("No open TCP connections");
    }
  }

  if(servercfg->applications_thread) { 
    LogProcMessage("Stopping CM applications_thread");
    if(servercfg->applications_thread->GetThreadState() == gxTHREAD_STATE_RUNNING) {
      t.CancelThread(servercfg->applications_thread);
      sSleep(1); // Allow I/O recovery time
      t.JoinThread(servercfg->applications_thread);
      if(servercfg->applications_thread->GetThreadState() == gxTHREAD_STATE_CANCELED) {
	LogProcMessage("CM applications_thread was halted");
      }
      else {
	LogProcMessage("CM applications_thread did not shutdown properly");
	error_level = 1;
      }
    }
    else {
      LogProcMessage("CM applications_thread was stopped");
    }
    if(error_level == 0) {   
      delete servercfg->applications_thread;
      servercfg->applications_thread = 0;
    }
  }
  else {
    LogProcMessage("CM applications_thread not active");
  }

  if(servercfg->services_thread) { 
    LogProcMessage("Stopping CM services_thread");
    if(servercfg->services_thread->GetThreadState() == gxTHREAD_STATE_RUNNING) {
      t.CancelThread(servercfg->services_thread);
      sSleep(1); // Allow I/O recovery time
      t.JoinThread(servercfg->services_thread);
      if(servercfg->services_thread->GetThreadState() == gxTHREAD_STATE_CANCELED) {
	LogProcMessage("CM services_thread was halted");
      }
      else {
	LogProcMessage("CM services_thread did not shutdown properly");
	error_level = 1;
      }
    }
    else {
      LogProcMessage("CM services_thread was stopped");
    }
    if(error_level == 0) {
      delete servercfg->services_thread;
      servercfg->services_thread = 0;
    }
  }
  else {
    LogProcMessage("CM services_thread not active");
  }

  if(servercfg->filesystems_thread) { 
    LogProcMessage("Stopping CM filesystems_thread");
    if(servercfg->filesystems_thread->GetThreadState() == gxTHREAD_STATE_RUNNING) {
      t.CancelThread(servercfg->filesystems_thread);
      sSleep(1); // Allow I/O recovery time
      t.JoinThread(servercfg->filesystems_thread);
      if(servercfg->filesystems_thread->GetThreadState() == gxTHREAD_STATE_CANCELED) {
	LogProcMessage("CM filesystems_thread was stopped");
      }
      else {
	LogProcMessage("CM filesystems_thread did not shutdown properly");
	error_level = 1;
      }
    }
    else {
      LogProcMessage("CM filesystems_thread was halted");
    }
    if(error_level == 0) {
      delete servercfg->filesystems_thread;
      servercfg->filesystems_thread = 0;
    }
  }
  else {
    LogProcMessage("CM filesystems_thread not active");
  }


  // Stop the log thread last
  if(servercfg->log_thread) { 
    LogProcMessage("Stopping log thread");
    LogThread log;
    if(servercfg->log_thread->GetThreadState() == gxTHREAD_STATE_RUNNING) {
      log.CancelThread(servercfg->log_thread);
      sSleep(1);
      log.JoinThread(servercfg->log_thread);
      if(servercfg->log_thread->GetThreadState() == gxTHREAD_STATE_CANCELED) {
	LogProcMessage("Log thread was halted");
      }
      else {
	LogProcMessage("Log thread did not shutdown properly");
	error_level = 1;
      }
    }
    else {
      LogProcMessage("Log thread was stopped");
    }
    if(error_level == 0) {
      delete servercfg->log_thread;
      servercfg->log_thread = 0;
    }
  }
  else {
    LogProcMessage("Log thread not active");
  }

  LogThread log_t;
  log_t.flush_all_logs();

  return error_level;
}
void ProcessThread::installProcessHandler()
{
    assert(sProcessThread == 0);
    sProcessThread = new ProcessThread;
    sProcessThread->start();
}
示例#4
0
ProcessingDialog::~ProcessingDialog(void)
{
	ui->view_log->setModel(NULL);

	if(m_progressIndicator)
	{
		m_progressIndicator->stop();
	}

	if(m_diskObserver)
	{
		m_diskObserver->stop();
		if(!m_diskObserver->wait(15000))
		{
			m_diskObserver->terminate();
			m_diskObserver->wait();
		}
	}
	if(m_cpuObserver)
	{
		m_cpuObserver->stop();
		if(!m_cpuObserver->wait(15000))
		{
			m_cpuObserver->terminate();
			m_cpuObserver->wait();
		}
	}
	if(m_ramObserver)
	{
		m_ramObserver->stop();
		if(!m_ramObserver->wait(15000))
		{
			m_ramObserver->terminate();
			m_ramObserver->wait();
		}
	}

	while(!m_threadList.isEmpty())
	{
		ProcessThread *thread = m_threadList.takeFirst();
		thread->terminate();
		thread->wait(15000);
		delete thread;
	}

	LAMEXP_DELETE(m_progressIndicator);
	LAMEXP_DELETE(m_systemTray);
	LAMEXP_DELETE(m_diskObserver);
	LAMEXP_DELETE(m_cpuObserver);
	LAMEXP_DELETE(m_ramObserver);
	LAMEXP_DELETE(m_progressViewFilterGroup);
	LAMEXP_DELETE(m_filterInfoLabel);
	LAMEXP_DELETE(m_filterInfoLabelIcon);
	LAMEXP_DELETE(m_contextMenu);
	LAMEXP_DELETE(m_progressModel);

	WinSevenTaskbar::setOverlayIcon(this, NULL);
	WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNoState);

	LAMEXP_DELETE(ui);
}
示例#5
0
int main()
{
	bool fileRead = true;

	int frameWidth = 1024;
	int frameHeight =300;
	int framesPerBuffer = 30; //This value needs to be divisble by 3, and a factor of the total number of frames
	int samplingMethod  = 0; //0 for Interpolation, 1 for Fast Cubic, 2 for Pref Cubic
	int volumeFrames = 900; //Useless for this code

//OpenGL ONLY Variables to be transferred
	bool processData = true;  //MUST be true
	bool fundusRender = true; //Can be false or true
	bool volumeRender = false; //Volume render currently does not work with speckle variance in this version of the code
	int fileLen;
	int bufferLen;
	int windowWidth = 1080;
	int windowHeight = 720;

	buffer *h_buffer = new buffer[BUFFNUM];
	int buffCtr = 0;
	unsigned short *h_ProcBuffer;

	bool *registeredHost;

	enum volumeDisplay {DownSize, Crop};
	volumeDisplay volumeMode = Crop;

//CUDA ONLY Variables to be transferred
	int fftLenMult = 2;
	float dispMag = 10;
	float dispVal = -6.5f * pow(0.1f,5);
	float dispValThird = 0;

	//Calculation of lookupLambda Coordinates
	float lambda_Max= LAMBDA_MIN	+	(frameWidth-1) * D_LAMBDA	+
					pow((frameWidth-1.0f),2) * SECOND_ORDER_CORRECTION	+
					pow((frameWidth-1.0f),3) * THIRD_ORDER_CORRECTION	+
					pow((frameWidth-1.0f),4) * FOURTH_ORDER_CORRECTION;
// END OF DEFINING CUDA VARIABLES

	//Define the filename of the file to be used for acquisition simulation
	char *fileName = new char[100];
//	fileName = "c:\\OCTViewer\\SDD\\fullvolume"; 
	dispVal = 2.3f * pow(0.1f,5);
//fileName = "F:\\RightEye(042213)\\WT_Scratchback_PV_R_4-ON---1.unp"; dispVal = 2.3f * pow(0.1f,5);
//fileName = "F:\\SS-OCT\\SS-OCT\\For Robert\\ssdata.dat";
	fileName = "f:\\Jing\\SPIE\\mouse data\\800middle-ON---1";	
	//fileName = "G:\\randow\\09192013\\2500-ON---1.unp";
		//  fileName = "g:\\randow\\SVTest3-ON---1.unp";
//fileName = "c:\\OCTViewer\\SDD\\fullvolume"; dispVal = 2.3f * pow(0.1f,5);


	FILE *file = fopen(fileName, "rb");
	if (file==NULL)
	{	printf("Unable to Open file. Exiting Program...\n"); exit(1);}
	fseek(file, 0, SEEK_END);
	fileLen=ftell(file)/(int)sizeof(unsigned short);
	fclose(file);


	if (fileRead) {
		bufferLen = fileLen;
		volumeFrames = fileLen / (frameWidth*frameHeight);
	} 
	else if (volumeRender || fundusRender) {
		bufferLen = frameWidth*frameHeight*volumeFrames;
	} else {
		bufferLen = frameWidth*frameHeight*framesPerBuffer;
	}

	for (int i=0; i<BUFFNUM; i++) {
		h_buffer[i].data = (unsigned short *)malloc(bufferLen * sizeof(unsigned short));
		h_buffer[i].regHost = false;
	}


//Initiate FileRead Thread
	FileReadThread FileRead;
	FileRead.create();
	FileRead.InitFileRead(fileName, h_buffer, &buffCtr, &bufferLen);

//Initiate the Process Thread
	ProcessThread Proc;
	Proc.create();
	Proc.InitProcess(	h_buffer, &buffCtr, processData, volumeRender, fundusRender,
						frameWidth, frameHeight, framesPerBuffer,volumeFrames, bufferLen, 
						windowWidth, windowHeight, samplingMethod, (int)volumeMode, fftLenMult,
						LAMBDA_MIN, lambda_Max, dispMag, dispVal, dispValThird);
//END OF INITIALIZATION
//Begin Process Thread
	FileRead.start();
	Proc.start();
	FileRead.join();
	Proc.join();

	return 0;
}
示例#6
0
int main()
{
	bool fileRead = false;

	int frameWidth = 1024;
	int frameHeight = 300;
	int framesPerBuffer = 20;
	int volumeSize = 100;


//OpenGL ONLY Variables to be transferred
	//Process Data MUST be true
	//Display pre-processed data currently does NOT work!!
	bool processData = true;  //MUST be true
	bool fundusRender = true; //Can be false or true
	bool volumeRender = true; //Can be false or true
	int fileLen;
	int bufferLen;
	int windowWidth = 1024;
	int windowHeight = 1024;
	buffer *h_buffer = new buffer[BUFFNUM];
	int buffCtr = 0;
	unsigned short *h_ProcBuffer;
	bool *registeredHost;
	enum volumeDisplay {DownSize, Crop};
	volumeDisplay volumeMode = Crop;

//CUDA ONLY Variables to be transferred
	int fftLenMult = 2;
// END OF DEFINING CUDA VARIABLES

	//Define the filename to be used for file acquisition simulation
	char *fileName = new char[100];
	fileName = "../../../.data/Mouse-Dataset.unp";

	FILE *file = fopen(fileName, "rb");
	if (file==NULL)
	{	printf("Unable to Open file. Exiting Program...\n"); exit(1);}
	fseek(file, 0, SEEK_END);
	fileLen=ftell(file)/(int)sizeof(unsigned short);
	fclose(file);
	
	if (volumeRender || fundusRender) {
		if (fileRead) {
			bufferLen = fileLen;
		} else {
			bufferLen = frameWidth*frameHeight*volumeSize;
		}
	} else {
		bufferLen = frameWidth*frameHeight*framesPerBuffer;
	}

	for (int i=0; i<BUFFNUM; i++) {
		h_buffer[i].data = (unsigned short *)malloc(bufferLen * sizeof(unsigned short));
		h_buffer[i].regHost = false;
	}


//Initiate FileRead Thread
	FileReadThread FileRead;
	FileRead.create();
	FileRead.InitFileRead(fileName, h_buffer, &buffCtr, &bufferLen);

//Initiate the Process Thread
	ProcessThread Proc;
	Proc.create();
	Proc.InitProcess(	h_buffer, &buffCtr, processData, volumeRender, fundusRender, 
						frameWidth, frameHeight, framesPerBuffer, bufferLen, 
						windowWidth, windowHeight, (int)volumeMode, fftLenMult);
//END OF INITIALIZATION
//Begin Process Thread
	FileRead.start();
	Proc.start();
	FileRead.join();
	Proc.join();

	return 0;
}