Example #1
0
void InitCycle(std::shared_ptr<NamedPipe>& pipe)
{
   auto globals = globalStruct::GetGlobals();
   if (!globals)
      return;
   auto svc = globals->GetService();
   if (!svc)
      return;
   std::atomic_store(&globals->pipe, pipe);
   StartRecv(pipe);

   svc->post([pipe, globals]()
                          {
                             if (!pipe || !pipe->IsConnected())
                                return;
                             auto strm = globals->GetStreamer();
                             if (!strm)
                                return;
                             try
                             {
                                Writer MyWriter(pipe);
                                strm->startStream(MyWriter);
                                strm->stream(MyWriter);
                             }
                             catch (NamedPipeException& ex)
                             {
                                pipe->Cleanup();
                             }
                          });
}