当前位置: 首页>>代码示例>>C++>>正文


C++ Dispatcher::interrupted方法代码示例

本文整理汇总了C++中Dispatcher::interrupted方法的典型用法代码示例。如果您正苦于以下问题:C++ Dispatcher::interrupted方法的具体用法?C++ Dispatcher::interrupted怎么用?C++ Dispatcher::interrupted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dispatcher的用法示例。


在下文中一共展示了Dispatcher::interrupted方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: context

TEST(ContextGroupTests, DispatcherInterruptSetsFlag) {
  Dispatcher dispatcher;
  Context<> context(dispatcher, [&] {
    try {
      Timer(dispatcher).sleep(std::chrono::milliseconds(10));
    } catch (InterruptedException&) {
    }
  });

  dispatcher.interrupt();
  dispatcher.yield();
  ASSERT_TRUE(dispatcher.interrupted());
  ASSERT_FALSE(dispatcher.interrupted());
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:14,代码来源:ContextGroupTests.cpp

示例2: InterruptedException

TEST(ContextTests, interruptIsInterrupting) {
  Dispatcher dispatcher;
  Context<> context(dispatcher, [&] {
    if (dispatcher.interrupted()) {
      throw InterruptedException();
    }
  });

  context.interrupt();
  ASSERT_THROW(context.get(), InterruptedException);
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:11,代码来源:ContextTests.cpp

示例3: context

TEST(ContextTests, destructorInterrupts) {
  Dispatcher dispatcher;
  bool interrupted = false;
  {
    Context<> context(dispatcher, [&] {
      if (dispatcher.interrupted()) {
        interrupted = true;
      }
    });
  }

  ASSERT_TRUE(interrupted);
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:13,代码来源:ContextTests.cpp

示例4:

TEST(ContextGroupTests, ContextGroupInterruptIsInterrupting) {
  Dispatcher dispatcher;

  bool interrupted = false;
  ContextGroup cg1(dispatcher);
  cg1.spawn([&] {
    interrupted = dispatcher.interrupted();
  });

  cg1.interrupt();
  cg1.wait();

  ASSERT_TRUE(interrupted);
} 
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:14,代码来源:ContextGroupTests.cpp

示例5: Timer

TEST(ContextGroupTests, ContextGroupDestructorIsInterrupt_Waitable) {
  Dispatcher dispatcher;

  bool interrupted = false;
  bool contextFinished = false;
  {
    ContextGroup cg1(dispatcher);
    cg1.spawn([&] {
      interrupted = dispatcher.interrupted();
      Timer(dispatcher).sleep(std::chrono::milliseconds(100));
      contextFinished = true;
    });
  }

  ASSERT_TRUE(interrupted);
  ASSERT_TRUE(contextFinished);
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:17,代码来源:ContextGroupTests.cpp

示例6: event

TEST(ContextTests, getChecksInterruption) {
  Dispatcher dispatcher;
  Event event(dispatcher);
  Context<int> context1(dispatcher, [&] {
    event.wait();
    if (dispatcher.interrupted()) {
      return 11;
    }

    return 10;
  });

  Context<int> context2(dispatcher, [&] {
    event.set();
    return context1.get();
  });

  context2.interrupt();
  ASSERT_EQ(11, context2.get());
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:20,代码来源:ContextTests.cpp


注:本文中的Dispatcher::interrupted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。