Пример #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();
}
Пример #2
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&)
	  {
	  }
      }
  }