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


C++ promise::get_future方法代码示例

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


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

示例1: f

	/**
	*	@brief	Construct a fence object in unsignaled state
	*/
	shared_fence(const vk::vk_logical_device<> &device,
				 const char *name)
		: f(device, 
			name,
			false), 
		future(promise.get_future().share())
	{}
开发者ID:ssteinberg,项目名称:ste,代码行数:10,代码来源:shared_fence.hpp

示例2: doit

 std::future<int> doit()
 {
   BARK();
   auto cb = [&](const boost::system::error_code&) {
     std::cout << "CB!\n";
     prom.set_value(13);
   };
   dt.async_wait(cb);
   return prom.get_future();
 }
开发者ID:straszheim,项目名称:cpp-study,代码行数:10,代码来源:promfut.cpp

示例3: invalid_argument

	Impl(GeneratorHandler &handler, const QString &fileName)
		: m_handler(handler)
		, m_outp(fileName.toStdString())
		, m_thread(&Impl::ThreadFunction, this)
	{
		if (!m_outp.is_open())
			throw std::invalid_argument("Cannot write to " + fileName.toStdString());

		auto threadStartWaiter = m_promice.get_future();
		threadStartWaiter.get();
	}
开发者ID:heimdallr,项目名称:home_compa_dev,代码行数:11,代码来源:ResultSaver.cpp

示例4: set

 FM<T>& set(SM<T, Ts...>& input, const bool is_lazy, Ts&... args) {
     _promise = std::promise<T>();
     _future = _promise.get_future();
     auto f = std::async(
         is_lazy ? std::launch::deferred : std::launch::async,
         [&] () {
             task_loop<T, Ts...>()(input, _promise, args...);
         }
     );
     if(is_lazy) f.get();
     return *this;
 };
开发者ID:diegoperini,项目名称:cppnow2014-doppl,代码行数:12,代码来源:doppl_future_member.hpp

示例5: dispatch

    interfaceHandlerDBusConnection->unregisterObjectPath(objectPath);

    ASSERT_TRUE(interfaceHandlerDBusConnection->releaseServiceName(busName));
    interfaceHandlerDBusConnection->disconnect();
}

void dispatch(::DBusConnection* libdbusConnection) {
    dbus_bool_t success = TRUE;
    while (success) {
        success = dbus_connection_read_write_dispatch(libdbusConnection, 1);
    }
}

std::promise<bool> promise;
std::future<bool> future = promise.get_future();

void notifyThunk(DBusPendingCall*, void* data) {
    ::DBusConnection* libdbusConnection = reinterpret_cast<DBusConnection*>(data);
    dbus_connection_close(libdbusConnection);
    dbus_connection_unref(libdbusConnection);
    promise.set_value(true);
}

TEST_F(DBusConnectionTest, LibdbusConnectionsMayCommitSuicide) {
    const ::DBusBusType libdbusType = ::DBusBusType::DBUS_BUS_SESSION;
    ::DBusError libdbusError;
    dbus_error_init(&libdbusError);
    ::DBusConnection* libdbusConnection = dbus_bus_get_private(libdbusType, &libdbusError);

    assert(libdbusConnection);
开发者ID:Pelagicore,项目名称:common-api-dbus-runtime,代码行数:30,代码来源:DBusConnectionTest.cpp

示例6: reset

	/**
	*	@brief	Resets fence to unsignaled state
	*			Not thread-safe.
	*/
	void reset() override {
		f.reset();
		promise = std::promise<R>();
		future = promise.get_future().share();
	}
开发者ID:ssteinberg,项目名称:ste,代码行数:9,代码来源:shared_fence.hpp

示例7: getFuture

		std::future<T> getFuture()
		{
			return result->get_future();
		}
开发者ID:r-lyeh-forks,项目名称:AGE,代码行数:4,代码来源:message.hpp

示例8: join

 void join()
 {
     std::future<void> future = stop_promise.get_future();
     future.get();
 }
开发者ID:ska-sa,项目名称:spead2,代码行数:5,代码来源:test_recv.cpp

示例9: main


//.........这里部分代码省略.........

  // Reading public and private key files
  iroha::KeysManagerImpl keysManager(FLAGS_keypair_name);
  auto keypair = keysManager.loadKeys();
  // Check if both keys are read properly
  if (not keypair) {
    // Abort execution if not
    log->error("Failed to load keypair");
    return EXIT_FAILURE;
  }

  // Configuring iroha daemon
  Irohad irohad(config[mbr::BlockStorePath].GetString(),
                config[mbr::PgOpt].GetString(),
                config[mbr::ToriiPort].GetUint(),
                config[mbr::InternalPort].GetUint(),
                config[mbr::MaxProposalSize].GetUint(),
                std::chrono::milliseconds(config[mbr::ProposalDelay].GetUint()),
                std::chrono::milliseconds(config[mbr::VoteDelay].GetUint()),
                std::chrono::milliseconds(config[mbr::LoadDelay].GetUint()),
                *keypair,
                config[mbr::MstSupport].GetBool());

  // Check if iroha daemon storage was successfully initialized
  if (not irohad.storage) {
    // Abort execution if not
    log->error("Failed to initialize storage");
    return EXIT_FAILURE;
  }

  // Check if genesis block path was specified
  if (not FLAGS_genesis_block.empty()) {
    // If it is so, read genesis block and store it to iroha storage
    iroha::main::BlockLoader loader;
    auto file = loader.loadFile(FLAGS_genesis_block);
    auto block = loader.parseBlock(file.value());

    // Check that provided genesis block file was correct
    if (not block) {
      // Abort execution if not
      log->error("Failed to parse genesis block");
      return EXIT_FAILURE;
    }

    // check if ledger data already existing
    auto ledger_not_empty =
        irohad.storage->getBlockQuery()->getTopBlockHeight() != 0;

    // Check if force flag to overwrite ledger is specified
    if (ledger_not_empty && not FLAGS_overwrite_ledger) {
      log->error(
          "Block store not empty. Use '--overwrite_ledger' to force "
          "overwrite it. Shutting down...");
      return EXIT_FAILURE;
    }

    // clear previous storage if any
    irohad.dropStorage();

    // reset ordering service persistent counter
    irohad.resetOrderingService();

    log->info("Block is parsed");

    // Applying transactions from genesis block to iroha storage
    irohad.storage->insertBlock(*block.value());
    log->info("Genesis block inserted, number of transactions: {}",
              block.value()->transactions().size());
  }

  // check if at least one block is available in the ledger
  auto blocks_exist = irohad.storage->getBlockQuery()->getTopBlock().match(
      [](const auto &) { return true; },
      [](iroha::expected::Error<std::string> &) { return false; });

  if (not blocks_exist) {
    log->error(
        "There are no blocks in the ledger. Use --genesis_block parameter.");
    return EXIT_FAILURE;
  }

  // init pipeline components
  irohad.init();

  auto handler = [](int s) { exit_requested.set_value(); };
  std::signal(SIGINT, handler);
  std::signal(SIGTERM, handler);
  std::signal(SIGQUIT, handler);

  // runs iroha
  log->info("Running iroha");
  irohad.run();
  exit_requested.get_future().wait();

  // We do not care about shutting down grpc servers
  // They do all necessary work in their destructors
  log->info("shutting down...");

  return 0;
}
开发者ID:kevinmcmahon,项目名称:iroha,代码行数:101,代码来源:irohad.cpp


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