void ezPipeChannel_win::InternalDisconnect()
{
#if EZ_ENABLED(EZ_COMPILE_FOR_DEBUG)
  if (m_ThreadId != 0)
    EZ_ASSERT_DEBUG(m_ThreadId == ezThreadUtils::GetCurrentThreadID(), "Function must be called from worker thread!");
#endif
  if (m_InputState.IsPending || m_OutputState.IsPending)
  {
    CancelIo(m_PipeHandle);
  }

  if (m_PipeHandle != INVALID_HANDLE_VALUE)
  {
    CloseHandle(m_PipeHandle);
    m_PipeHandle = INVALID_HANDLE_VALUE;
  }

  while (m_InputState.IsPending || m_OutputState.IsPending)
  {
    FlushPendingOperations();
  }

  {
    EZ_LOCK(m_OutputQueueMutex);
    m_OutputQueue.Clear();
    m_Connected = false;
  }

  m_Events.Broadcast(ezIpcChannelEvent(m_Mode == Mode::Client ? ezIpcChannelEvent::DisconnectedFromServer : ezIpcChannelEvent::DisconnectedFromClient, this));
  // Raise in case another thread is waiting for new messages (as we would sleep forever otherwise).
  m_IncomingMessages.RaiseSignal();
}
void
GamepadServiceTest::ActorCreated(PBackgroundChild* aActor)
{
  MOZ_ASSERT(aActor);
  // If we are shutting down, we don't need to create the
  // IPDL child/parent pair anymore.
  if (mShuttingDown) {
    // mPendingOperations should be cleared in
    // DestroyPBackgroundActor()
    MOZ_ASSERT(mPendingOperations.IsEmpty());
    return;
  }

  mChild = new GamepadTestChannelChild();
  PGamepadTestChannelChild* initedChild =
    aActor->SendPGamepadTestChannelConstructor(mChild);
  if (NS_WARN_IF(!initedChild)) {
    ActorFailed();
    return;
  }
  FlushPendingOperations();
}