Example #1
0
void DBManager::OnPluginUnloaded(IPlugin *plugin)
{
	/* Kill the thread so we can flush everything into the think queue... */
	KillWorkerThread();

	/* Mark the plugin as being unloaded so future database calls will ignore threading... */
	plugin->SetProperty("DisallowDBThreads", NULL);

	/* Run all of the think operations.
	 * Unlike the driver unloading example, we'll let these calls go through, 
	 * since a plugin unloading is far more normal.
	 */
	Queue<IDBThreadOperation *>::iterator iter = m_ThinkQueue.begin();
	Queue<IDBThreadOperation *> templist;
	while (iter != m_ThinkQueue.end())
	{
		IDBThreadOperation *op = (*iter);
		if (op->GetOwner() == plugin->GetIdentity())
		{
			templist.push(op);
			iter = m_ThinkQueue.erase(iter);
		} else {
			iter++;
		}
	}

	for (iter = templist.begin();
		 iter != templist.end();
		 iter++)
	{
		IDBThreadOperation *op = (*iter);
		op->RunThinkPart();
		op->Destroy();
	}
}
Example #2
0
void DBManager::RemoveDriver(IDBDriver *pDriver)
{
	/* Again, we're forced to kill the worker.  How rude!
	 * Doing this flushes the queue, and thus we don't need to 
	 * clean anything else.  
	 */
	KillWorkerThread();

	for (size_t i=0; i<m_drivers.size(); i++)
	{
		if (m_drivers[i] == pDriver)
		{
			m_drivers.erase(m_drivers.iterAt(i));
			break;
		}
	}

	/* Make sure NOTHING references this! */
	List<ConfDbInfo *>::iterator iter;
	for (iter=m_confs.begin(); iter!=m_confs.end(); iter++)
	{
		ConfDbInfo &db = *(*iter);
		if (db.realDriver == pDriver)
		{
			db.realDriver = NULL;
		}
	}

	/* Someone unloaded the default driver? Silly.. */
	if (pDriver == m_pDefault)
	{
		m_pDefault = NULL;
	}

	/* Now that the driver is gone, we have to test the think queue.
	 * Whatever happens therein is up to the db op!
	 */
	Queue<IDBThreadOperation *>::iterator qiter = m_ThinkQueue.begin();
	Queue<IDBThreadOperation *> templist;
	while (qiter != m_ThinkQueue.end())
	{
		IDBThreadOperation *op = (*qiter);
		if (op->GetDriver() == pDriver)
		{
			templist.push(op);
			qiter = m_ThinkQueue.erase(qiter);
		} else {
			qiter++;
		}
	}

	for (qiter = templist.begin();
		 qiter != templist.end();
		 qiter++)
	{
		IDBThreadOperation *op = (*qiter);
		op->CancelThinkPart();
		op->Destroy();
	}
}
Example #3
0
void DBManager::OnSourceModShutdown()
{
	g_pSM->RemoveGameFrameHook(&FrameHook);
	KillWorkerThread();
	g_PluginSys.RemovePluginsListener(this);
	g_HandleSys.RemoveType(m_DatabaseType, g_pCoreIdent);
	g_HandleSys.RemoveType(m_DriverType, g_pCoreIdent);
	ClearConfigs();
}
Example #4
0
void DBManager::AddDriver(IDBDriver *pDriver)
{
	 /* Let's kill the worker.  Join the thread and let the queries flush.
	  * This is kind of stupid but we just want to unload safely.
	  * Rather than recreate the worker, we'll wait until someone throws 
	  * another query through.
	  */
	KillWorkerThread();

	 m_drivers.push_back(pDriver);
}
Example #5
0
/*
 * Function:	WorkerLoop
 *
 * Description:	called from the base class (periodically)
 *
 * Parameters:
 *		int		count
 * 
 * Return Values
 *		none
 *
 * Discussion:
 *				performs the diagnostic
 */
void
TCDSti::WorkerLoop(void)
{
	// if we are are ready working, discontinue;
	if (m_Continue == TRUE)
		m_Continue = FALSE;
	else
	{
		m_Continue = TRUE;
		m_StiButton.SetWindowText("Cancel");
		// disable movement
		m_StiRotateCCButton.EnableWindow(FALSE);
		m_StiRotateCButton.EnableWindow(FALSE);
		m_StiMoveUpButton.EnableWindow(FALSE);
		m_StiMoveLeftButton.EnableWindow(FALSE);
		m_StiMoveDownButton.EnableWindow(FALSE);
		m_StiMoveRightButton.EnableWindow(FALSE);
		m_Slider.EnableWindow(FALSE);
		EnableLedButtons(FALSE);

		TestOuterDome();
//		if (m_Continue == TRUE) //F404 vc6版中已刪除
//			TestSplitter();

		// report on overall results
		CString diag = "Dome LED Tests: Completed: ";
		m_DiagPF     = (m_DomePF == DIAG_PASSED && m_SplitterPF == DIAG_PASSED)
							? DIAG_PASSED : DIAG_FAILED;
		if (m_DiagPF == DIAG_PASSED)
			DiagReport(diag, DIAG_PASSED);
		else
			DiagReport(diag, DIAG_FAILED);
	}

	// redraw the screen
	GetLeds();
	SnapShot(150, 100);

	m_StiButton.SetWindowText("STI Lights");

	m_StiRotateCCButton.EnableWindow(TRUE);
	m_StiRotateCButton.EnableWindow(TRUE);
	m_StiMoveUpButton.EnableWindow(TRUE);
	m_StiMoveLeftButton.EnableWindow(TRUE);
	m_StiMoveDownButton.EnableWindow(TRUE);
	m_StiMoveRightButton.EnableWindow(TRUE);
	m_Slider.EnableWindow(TRUE);
	EnableLedButtons(TRUE);

	// kill the worker thread
	KillWorkerThread();
	m_Continue   = FALSE;
}
Example #6
0
void DBManager::OnSourceModIdentityDropped(IdentityToken_t *pToken)
{
	s_pAddBlock = pToken;

	/* Kill the thread so we can flush everything into the think queue... */
	KillWorkerThread();

	/* Run all of the think operations.
 	 * Unlike the driver unloading example, we'll let these calls go through, 
	 * since a plugin unloading is far more normal.
	 */
	Queue<IDBThreadOperation *>::iterator iter = m_ThinkQueue.begin();
	Queue<IDBThreadOperation *> templist;
	while (iter != m_ThinkQueue.end())
	{
		IDBThreadOperation *op = (*iter);
		if (op->GetOwner() == pToken)
		{
			templist.push(op);
			iter = m_ThinkQueue.erase(iter);
		} else {
			iter++;
		}
	}

	for (iter = templist.begin();
		iter != templist.end();
		iter++)
	{
		IDBThreadOperation *op = (*iter);
		op->RunThinkPart();
		op->Destroy();
	}

	s_pAddBlock = NULL;
}