示例#1
0
文件: PrintJob.cpp 项目: mariuz/haiku
void
PrintServerMessenger::SetResult(BMessage* result)
{
	fResult = result;
	DeleteSemaphore();
	// terminate loop in thread spawned by SendRequest
}
示例#2
0
文件: PrintJob.cpp 项目: mariuz/haiku
PrintServerMessenger::~PrintServerMessenger()
{
	DeleteSemaphore();
		// in case SendRequest could not start the thread
	delete fRequest; fRequest = NULL;
	AllowUserInput();
}
	// Frees resources
	GaMultithreadingAlgorithm::~GaMultithreadingAlgorithm()
	{
		// free resources used by threads
		if( _threads )
		{
			for( int i = 0; i < _numberOfThreads; i++ )
			{
				if( _threads[ i ] )
					delete _threads[ i ];
			}

			// free thread pool
			delete[] _threads;
		}

		// free resources used by synchronization
		DeleteSemaphore( _workerForkSync );
		DeleteSemaphore( _workerJoinSync );
		DeleteEvent( _controlSync );
	}
示例#4
0
文件: utils.c 项目: AEUG/400plus
// this is a disassembled version of eventproc_release()
int shutter_release_disasm() {

	extern char * aRelSem;

	if (hRelSem == 0) {
		hRelSem = CreateBinarySemaphore(aRelSem, 0);
	}

	SendToIntercom(IC_RELEASE, 0, 0);
	SendToIntercom(0x6D, 1, 1); // set burst counter

	TakeSemaphore(hRelSem, 30000);
	DeleteSemaphore(hRelSem);
	hRelSem = 0;

	SleepTask(EVENT_WAIT); // we added this
	return 0;
}
示例#5
0
CMyRWLock::~CMyRWLock()
{
	DeleteCriticalSection(&m_CS);
	DeleteSemaphore(m_WriteSemaphore);
	DeleteSemaphore(m_ReadSemaphore);
}
	// Sets new parameters for algorithm
	void GaMultithreadingAlgorithm::SetAlgorithmParameters(const GaAlgorithmParams& parameters)
	{
		int newCount = ( (const GaMultithreadingAlgorithmParams&)parameters ).GetNumberOfWorkers();

		// state of algorithm couldnot be changed during parameter change
		BlockStateChange();

		int oldCount = _numberOfThreads - 1;

		// nothing changed?
		if( oldCount == newCount )
		{
			// now it safe to change state of algorithm
			ReleaseStateChange();
			return;
		}

		// if algorithm is running - stop all worker threads
		if( _state == GAS_RUNNING )
		{
			_parametersChange = true;

			// release working threads
			_workersThreadOut = _workersThreadIn = oldCount;
			UnlockSemaphore( _workerForkSync, oldCount );

			// wait for working threads to be closed
			for( int i = 1; i <= oldCount; i++ )
				_threads[ i ]->Join();

			_parametersChange = false;
		}

		// remove synchronization objects
		DeleteSemaphore( _workerForkSync );
		DeleteSemaphore( _workerJoinSync );

		// make new synchronization object
		MakeSemaphore( _workerForkSync, newCount, 0 );
		MakeSemaphore( _workerJoinSync, newCount, 0 );

		// new thread pool
		GaThread** newThreads = new GaThread*[ newCount + 1 ];

		// copy old needed threads
		int lim = min( oldCount, newCount ) + 1;
		for( int i = 0; i < lim; i++ )
			newThreads[ i ] = _threads[ i ];

		if( oldCount < newCount )
		{
			// new threads should be added

			// new worker threads' parameters
			GaThreadParameter p;
			p._functionPointer = WorkFlowWrapper;
			p._functionParameters = this;

			// make new threads
			for( int i = newCount - oldCount + 1; i < newCount; i++ )
				newThreads[ i ] = new GaThread( p, false );
		}
		else
		{
			// threads should be remove

			// free old threads
			for( int i = oldCount - newCount + 1; i < oldCount; i++ )
				delete _threads[ i ];
		}

		// swap pool of threads
		delete[] _threads;
		_threads = newThreads;
		_numberOfThreads = newCount + 1;

		// restart working threads if they were running
		if( _state == GAS_RUNNING )
		{
			for( int i = 1; i <= newCount; i++ )
				_threads[ i ]->Start();
		}

		// now it safe to change state of algorithm
		ReleaseStateChange();
	}
示例#7
0
/*-----------------------------------------------------------------------------
|   Function        :   sflash_deinit
|
|   Parameters      :   None
|
|   Return Value    :   None
|
|   Notes           :   
+----------------------------------------------------------------------------*/
void sflash_deinit()
{
   DeleteSemaphore(sSFlashInUseSem);
}