void Sendr::postMessage(const MessageS& msg)
{
  sendQ_.enQ(msg);
  string file = FileSystem::Path::fileSpec("../TESTFOLDERCLIENT1", "test.txt");
  string filepath = FileSystem::Path::getFullFileSpec(file);
  Client1 c1("localhost","1001","localhost","2001",filepath);
  c1.enQueue("TEST_FILE_REQUEST",filepath);
}
示例#2
0
void main() {

  cout << "\n  Demonstrating basic Queue operations with the BlockingQueue<T> class "
       << "\n ======================================================================\n";

  BQueue<int> intQ;
  intQ.enQ(1);
  intQ.enQ(2);
  intQ.enQ(3);

  BQueue<int> intQ2 = intQ;
  cout << "\n  copy construction: intQ2.size() = " << intQ2.size();
  intQ2.clear();
  cout << "\n  after intQ2.clear(), intQ2.size() = " << intQ2.size();

  BQueue<int> intQ3;
  intQ3 = intQ;
  cout << "\n  after assignment: intQ3.size() = " << intQ3.size();

  cout << "\n  intQ3 contents: " 
       << intQ3.deQ() << "," << intQ3.deQ() << "," << intQ3.deQ() << "\n\n";

  cout << "\n  Demonstrating BlockingQueue<T> message handling "
       << "\n =================================================\n";

  BQueue<std::string> sQ;
  threadproc tp(sQ);
  thread th(tp);
  th.start();
  std::string msg;
  ostringstream out;

  for(int i=0; i<20; ++i)
  {
    out.str("");
    out << i;
    msg = std::string("msg #") + out.str() + std::string(" - a message");
    sout << locker << "\n  sending msg \"" << msg << "\"" << unlocker;
    sQ.enQ(msg);
  }
  msg = std::string("quit");
  sout << locker << "\n  sending msg \"" << msg << "\"" << unlocker;
  sQ.enQ(msg);
  th.wait();
}
void MockChannel::start()
{
  std::cout << "\n  MockChannel starting up";
  thread_ = std::thread(
    [this] {
    while (!stop_)
    {
      std::cout << "\n  channel deQing message";
	  MessageS msg = sendQ_.deQ();  // will block here so send quit message when stopping
	  std::cout << "\n  channel enQing message";
      recvQ_.enQ(msg);
	  std::cout << msg;
	}
    std::cout << "\n  Server stopping\n\n";
  });
}
void MockChannel::postMessage(const MessageS& cmd, const MessageS& parameter)
{
	c1.enQueue(cmd, parameter);
	sendQ_.enQ(cmd);
	sendQ_.enQ(parameter);
}