Exemple #1
0
int PooledThread::idleTime()
{
	FastMutex::ScopedLock lock(_mutex);

#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
	return (int) (wceex_time(NULL) - _idleTime);
#else
	return (int) (time(NULL) - _idleTime);
#endif	
}
Exemple #2
0
PooledThread::PooledThread(const std::string& name, int stackSize): 
	_idle(true), 
	_idleTime(0), 
	_pTarget(0), 
	_name(name), 
	_thread(name),
	_targetCompleted(false)
{
	poco_assert_dbg (stackSize >= 0);
	_thread.setStackSize(stackSize);
#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
	_idleTime = wceex_time(NULL);
#else
	_idleTime = std::time(NULL);
#endif
}
Exemple #3
0
void GetCurrentDate(char *szDate)
{
	time_t t ;
	struct tm TP ;
	struct tm *p;

#ifdef _WIN32_WCE
	t = wceex_time(&t) ;
	memcpy(&TP, wceex_localtime(&t), sizeof(TP));
#else
	t = time(&t);
	memcpy(&TP, localtime(&t), sizeof(TP));	
#endif

	p = &TP;
	sprintf(szDate, "%04d%02d%02d", p->tm_year+1900, p->tm_mon+1, p->tm_mday);
}
Exemple #4
0
void PooledThread::run()
{
	_started.set();
	for (;;)
	{
		_targetReady.wait();
		_mutex.lock();
		if (_pTarget) // a NULL target means kill yourself
		{
			_mutex.unlock();
			try
			{
				_pTarget->run();
			}
			catch (Exception& exc)
			{
				ErrorHandler::handle(exc);
			}
			catch (std::exception& exc)
			{
				ErrorHandler::handle(exc);
			}
			catch (...)
			{
				ErrorHandler::handle();
			}
			FastMutex::ScopedLock lock(_mutex);
			_pTarget  = 0;
#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
			_idleTime = wceex_time(NULL);
#else
			_idleTime = time(NULL);
#endif	
			_idle     = true;
			_targetCompleted.set();
			ThreadLocalStorage::clear();
			_thread.setName(_name);
			_thread.setPriority(Thread::PRIO_NORMAL);
		}
		else
		{
			_mutex.unlock();
			break;
		}
	}
}