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


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

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


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

示例1: setupRuntime

 void setupRuntime(std::promise<bool>& p) {
     runtime_ = CommonAPI::Runtime::load();
     p.set_value(true);
 }
开发者ID:gokul711,项目名称:common-api-tools,代码行数:4,代码来源:MainLoopVerification.cpp

示例2: set_promise

 void set_promise(std::promise<void>& p, F f)
 {
     f();
     p.set_value();
 }   
开发者ID:WhiZTiM,项目名称:coliru,代码行数:5,代码来源:main.cpp

示例3: findEvents

void findEvents(std::size_t /*tid*/, data_iter_t begin, data_iter_t end, nl_bounds nlBounds,
                const CPUKernel *const kernel, scalar dt, bool approximateRate, const neighbor_list &nl,
                event_promise_t &events, std::promise<std::size_t> &n_events) {
    std::vector<event_t> eventsUpdate;
    const auto &data = *kernel->getCPUKernelStateModel().getParticleData();
    const auto &box = kernel->context().boxSize().data();
    const auto &pbc = kernel->context().periodicBoundaryConditions().data();
    auto index = static_cast<std::size_t>(std::distance(data.begin(), begin));
    for (auto it = begin; it != end; ++it, ++index) {
        const auto &entry = *it;
        // this being false should really not happen, though
        if (!entry.deactivated) {
            // order 1
            {
                const auto &reactions = kernel->context().reactions().order1ByType(entry.type);
                for (auto it_reactions = reactions.begin(); it_reactions != reactions.end(); ++it_reactions) {
                    const auto rate = (*it_reactions)->rate();
                    if (rate > 0 && shouldPerformEvent(rate, dt, approximateRate)) {
                        eventsUpdate.emplace_back(1, (*it_reactions)->nProducts(), index, index, rate, 0,
                                                  static_cast<event_t::reaction_index_type>(it_reactions -
                                                                                            reactions.begin()),
                                                  entry.type, 0);
                    }
                }
            }
        }
    }
    for(auto cell = std::get<0>(nlBounds); cell != std::get<1>(nlBounds); ++cell) {
        for(auto particleIt = nl.particlesBegin(cell); particleIt != nl.particlesEnd(cell); ++particleIt) {
            const auto &entry = data.entry_at(*particleIt);
            if(entry.deactivated) {
                log::critical("deactivated entry in uncontrolled approximation!");
                continue;
            }

            nl.forEachNeighbor(*particleIt, cell, [&](const auto neighborIdx) {
                const auto &neighbor = data.entry_at(neighborIdx);
                if(!neighbor.deactivated) {
                    const auto &reactions = kernel->context().reactions().order2ByType(entry.type, neighbor.type);
                    if (!reactions.empty()) {
                        const auto distSquared = bcs::distSquared(neighbor.pos, entry.pos, box, pbc);
                        for (auto it_reactions = reactions.begin(); it_reactions < reactions.end(); ++it_reactions) {
                            const auto &react = *it_reactions;
                            const auto rate = react->rate();
                            if (rate > 0 && distSquared < react->eductDistanceSquared()
                                && shouldPerformEvent(rate, dt, approximateRate)) {
                                const auto reaction_index = static_cast<event_t::reaction_index_type>(it_reactions -
                                                                                                      reactions.begin());
                                eventsUpdate.emplace_back(2, react->nProducts(), *particleIt, neighborIdx,
                                                          rate, 0, reaction_index, entry.type, neighbor.type);
                            }
                        }
                    }
                }
            });
        }
    }

    n_events.set_value(eventsUpdate.size());
    events.set_value(std::move(eventsUpdate));
}
开发者ID:readdy,项目名称:readdy,代码行数:61,代码来源:CPUUncontrolledApproximation.cpp

示例4: set_value

void set_value( std::promise<void>& p, F& f, T& t ) { f(t); p.set_value(); }
开发者ID:CCJY,项目名称:coliru,代码行数:1,代码来源:main.cpp


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