text: /*
   * Copyright (c) 2018-2019, The Mybtcfx Developers.
   * Portions Copyright (c) 2012-2017, The CryptoNote Developers, The Bytecoin Developers.
   *
   * This file is part of 4xBIT.
   *
   * This file is subject to the terms and conditions defined in the
   * file 'LICENSE', which is part of this source code package.
   */
  
  #include "ContextGroupTimeout.h"
  #include <System/InterruptedException.h>
  
  using namespace System;
  
  ContextGroupTimeout::ContextGroupTimeout(Dispatcher& dispatcher, ContextGroup& contextGroup, std::chrono::nanoseconds timeout) :
    workingContextGroup(dispatcher),
    timeoutTimer(dispatcher) {
    workingContextGroup.spawn([&, timeout] {
      try {
        timeoutTimer.sleep(timeout);
        contextGroup.interrupt();
      } catch (InterruptedException&) {
      }
    });
  }
  