Esempio n. 1
0
/**
 * Executes the algorithms on a separate thread and waits for their completion.
 *
 * @return False if the batch was stopped due to error
 */
bool BatchAlgorithmRunner::executeBatch() {
  m_notificationCenter.addObserver(m_notificationObserver);
  Poco::ActiveResult<bool> result = m_executeAsync(Poco::Void());
  result.wait();
  m_notificationCenter.removeObserver(m_notificationObserver);
  return result.data();
}
Esempio n. 2
0
//----------------------------------------
//	TestAsyncNotify
//----------------------------------------
void TestAsyncNotify(ScopedLogMessage& msg)
{
	msg.Message("--- Async Notify ---");

	Poco::BasicEvent<TargetArgs>* pSource= reinterpret_cast<Poco::BasicEvent<TargetArgs>*>(new Source);
	Target target(0);
	(*pSource) += Poco::delegate(&target, &Target::onEvent);

	TargetArgs args = {msg, 78};
	Poco::ActiveResult<TargetArgs> retArg = pSource->notifyAsync(&target, args);
	delete pSource; // must work even when the event got deleted!
	pSource = NULL;

	retArg.wait();
}
Esempio n. 3
0
  void run(void)
  {
    const std::string prompt("TCPServer> ");
    char buffer[kNumRecieveBufferBytes+1] = {0};
    int numRead = 1;
 
    for(;numRead;)
      {
	try
	  {
	    socket().sendBytes(prompt.data(), static_cast<int>(prompt.length()));
 
	    numRead = socket().receiveBytes(buffer, kNumRecieveBufferBytes);
	    if(numRead)
	      {
		buffer[numRead] = 0;
		std::string str(buffer);
		Poco::replaceInPlace(str, "\r", "");
		Poco::replaceInPlace(str, "\n", "");
		Poco::toLowerInPlace(str);
		m_msg.Message(Poco::format("    TCPConnection::run received: %s", str));
 
		Poco::ActiveResult<std::string> result = m_dispatcher.process(str);
		result.wait();
 
		if(result.data().length())
		  {
		    socket().sendBytes(result.data().c_str(), static_cast<int>(result.data().length()));
		  }
	      }
	  }
	catch(Poco::Exception&)
	  {
	  }
      }
  }