• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ CPPA_REQUIRE函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中CPPA_REQUIRE函数的典型用法代码示例。如果您正苦于以下问题:C++ CPPA_REQUIRE函数的具体用法?C++ CPPA_REQUIRE怎么用?C++ CPPA_REQUIRE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: invoke

 bool invoke(Policy& policy, Client* client, mailbox_element* node) {
     CPPA_REQUIRE(!empty());
     CPPA_REQUIRE(client != nullptr);
     CPPA_REQUIRE(node != nullptr);
     // use a copy of bhvr, because invoked behavior might change m_elements
     auto id = m_elements.back().second;
     auto bhvr = m_elements.back().first;
     if (policy.invoke(client, node, bhvr, id)) {
         bool repeat;
         // try to match cached messages
         do {
             // remove synchronous response handler if needed
             if (id.valid()) {
                 erase_if([id](const element_type& value) {
                     return id == value.second;
                 });
             }
             if (!empty()) {
                 id = m_elements.back().second;
                 bhvr = m_elements.back().first;
                 repeat = policy.invoke_from_cache(client, bhvr, id);
             }
             else repeat = false;
         } while (repeat);
         return true;
     }
     return false;
 }
开发者ID:Fresh1,项目名称:libcppa,代码行数:28,代码来源:behavior_stack.hpp


示例2: invoke

 bool invoke(Policy& policy, Client* client, recursive_queue_node* node) {
     CPPA_REQUIRE(!m_elements.empty());
     CPPA_REQUIRE(client != nullptr);
     CPPA_REQUIRE(node != nullptr);
     // use a copy, because the invoked behavior might change m_elements
     behavior what = m_elements.back().first;
     auto id = m_elements.back().second;
     if (policy.invoke(client, node, what, id)) {
         // try to match cached messages
         do {
             // remove synchronous response handler if needed
             if (id.valid()) {
                 auto last = m_elements.end();
                 auto i = std::find_if(m_elements.begin(), last,
                                       [id](element_type& e) {
                                           return id == e.second;
                                       });
                 if (i != last) {
                     m_erased_elements.emplace_back(std::move(i->first));
                     m_elements.erase(i);
                 }
             }
             id = empty() ? message_id_t() : m_elements.back().second;
         } while (!empty() && policy.invoke_from_cache(client, back(), id));
         return true;
     }
     return false;
 }
开发者ID:Hegen,项目名称:libcppa,代码行数:28,代码来源:behavior_stack.hpp


示例3: enqueue_node

 bool enqueue_node(typename super::mailbox_element* node,
                   int next_state = ready) {
     CPPA_REQUIRE(node->marked == false);
     if (this->m_mailbox._push_back(node)) {
         for (;;) {
             int state = m_state.load();
             switch (state) {
                 case blocked: {
                     if (m_state.compare_exchange_weak(state, next_state)) {
                         CPPA_REQUIRE(this->m_scheduler != nullptr);
                         if (next_state == ready) {
                             this->m_scheduler->enqueue(this);
                         }
                         return true;
                     }
                     break;
                 }
                 case about_to_block: {
                     if (m_state.compare_exchange_weak(state, ready)) {
                         return false;
                     }
                     break;
                 }
                 default: return false;
             }
         }
     }
     return false;
 }
开发者ID:lihongjun,项目名称:libcppa,代码行数:29,代码来源:abstract_scheduled_actor.hpp


示例4: fetch_new_data

 // atomically sets m_stack back and enqueues all elements to the cache
 bool fetch_new_data(pointer end_ptr) {
     CPPA_REQUIRE(m_head == nullptr);
     CPPA_REQUIRE(!end_ptr || end_ptr == stack_empty_dummy());
     pointer e = m_stack.load();
     // must not be called on a closed queue
     CPPA_REQUIRE(e != nullptr);
     // it's enough to check this once, since only the owner is allowed
     // to close the queue and only the owner is allowed to call this
     // member function
     while (e != end_ptr) {
         if (m_stack.compare_exchange_weak(e, end_ptr)) {
             if (is_dummy(e)) {
                 // only use-case for this is closing a queue
                 CPPA_REQUIRE(end_ptr == nullptr);
                 return false;
             }
             while (e) {
                 CPPA_REQUIRE(!is_dummy(e));
                 auto next = e->next;
                 e->next = m_head;
                 m_head = e;
                 e = next;
             }
             return true;
         }
         // next iteration
     }
     return false;
 }
开发者ID:ras0219,项目名称:libcppa,代码行数:30,代码来源:single_reader_queue.hpp


示例5: decorated_tuple

    decorated_tuple(cow_pointer_type d, const vector_type& v)
        : super(tuple_impl_info::statically_typed)
        , m_decorated(std::move(d)), m_mapping(v) {
#       ifdef CPPA_DEBUG
        const cow_pointer_type& ptr = m_decorated; // prevent detaching
#       endif
        CPPA_REQUIRE(ptr->size() >= sizeof...(ElementTypes));
        CPPA_REQUIRE(v.size() == sizeof...(ElementTypes));
        CPPA_REQUIRE(*(std::max_element(v.begin(), v.end())) < ptr->size());
    }
开发者ID:alepharchives,项目名称:libcppa,代码行数:10,代码来源:decorated_tuple.hpp


示例6: synchronized_await

 void synchronized_await(Mutex& mtx, CondVar& cv) {
     CPPA_REQUIRE(!closed());
     if (try_block()) {
         std::unique_lock<Mutex> guard(mtx);
         while (blocked()) cv.wait(guard);
     }
 }
开发者ID:ras0219,项目名称:libcppa,代码行数:7,代码来源:single_reader_queue.hpp


示例7: switch

void abstract_scheduled_actor::enqueue_node(queue_node* node)
{
    if (m_mailbox._push_back(node))
    {
        for (;;)
        {
            int state = m_state.load();
            switch (state)
            {
                case blocked:
                {
                    if (m_state.compare_exchange_weak(state, ready))
                    {
                        CPPA_REQUIRE(m_scheduler != nullptr);
                        m_scheduler->enqueue(this);
                        return;
                    }
                    break;
                }
                case about_to_block:
                {
                    if (m_state.compare_exchange_weak(state, ready))
                    {
                        return;
                    }
                    break;
                }
                default: return;
            }
        }
    }
}
开发者ID:nilo72,项目名称:libcppa,代码行数:32,代码来源:abstract_scheduled_actor.cpp


示例8: CPPA_REQUIRE

void buffer::append_from(network::input_stream* istream) {
    CPPA_REQUIRE(remaining() > 0);
    auto num_bytes = istream->read_some(wr_ptr(), remaining());
    if (num_bytes > 0) {
        inc_size(num_bytes);
    }
}
开发者ID:alepharchives,项目名称:libcppa,代码行数:7,代码来源:buffer.cpp


示例9: operator

 inline void operator()(const actor_ptr& sender, const message_id& mid) const {
     CPPA_REQUIRE(rsn != exit_reason::not_exited);
     if (mid.is_request() && sender != nullptr) {
         sender->enqueue({nullptr, sender, mid.response_id()},
                         make_any_tuple(atom("EXITED"), rsn));
     }
 }
开发者ID:Zhouxiaoqing,项目名称:libcppa,代码行数:7,代码来源:sync_request_bouncer.hpp


示例10: CPPA_REQUIRE

actor_ptr default_actor_addressing::read(deserializer* source) {
    CPPA_REQUIRE(source != nullptr);
    auto cname = source->seek_object();
    if (cname == "@0") {
        CPPA_LOGMF(CPPA_DEBUG, self, "deserialized nullptr");
        source->begin_object("@0");
        source->end_object();
        return nullptr;
    }
    else if (cname == "@actor") {
        process_information::node_id_type nid;
        source->begin_object(cname);
        auto aid = source->read<uint32_t>();
        auto pid = source->read<uint32_t>();
        source->read_raw(process_information::node_id_size, nid.data());
        source->end_object();
        // local actor?
        auto pinf = process_information::get();
        if (pid == pinf->process_id() && nid == pinf->node_id()) {
            return get_actor_registry()->get(aid);
        }
        else {
            process_information tmp(pid, nid);
            return get_or_put(tmp, aid);
        }
    }
    else throw runtime_error("expected type name \"@0\" or \"@actor\"; "
                                 "found: " + cname);
}
开发者ID:purcaro,项目名称:libcppa,代码行数:29,代码来源:default_actor_addressing.cpp


示例11: assign

 void assign(InputIterator first, InputIterator last,
             // dummy SFINAE argument
             typename std::iterator_traits<InputIterator>::pointer = 0) {
     auto dist = std::distance(first, last);
     CPPA_REQUIRE(dist >= 0);
     resize(static_cast<size_t>(dist));
     std::copy(first, last, begin());
 }
开发者ID:ras0219,项目名称:libcppa,代码行数:8,代码来源:limited_vector.hpp


示例12: CPPA_REQUIRE

inline bool local_actor::awaits(message_id response_id) {
    CPPA_REQUIRE(response_id.is_response());
    return std::any_of(m_pending_responses.begin(),
                       m_pending_responses.end(),
                       [=](message_id other) {
                           return response_id == other;
                       });
}
开发者ID:Fresh1,项目名称:libcppa,代码行数:8,代码来源:local_actor.hpp


示例13: CPPA_LOG_TRACE

void middleman_event_handler::update() {
    CPPA_LOG_TRACE("");
    auto mless = [](const fd_meta_info& lhs, native_socket_type rhs) {
        return lhs.fd < rhs;
    };
    for (auto& elem_pair : m_alterations) {
        auto& elem = elem_pair.first;
        auto old = event::none;
        auto last = m_meta.end();
        auto iter = std::lower_bound(m_meta.begin(), last, elem.fd, mless);
        if (iter != last) old = iter->mask;
        auto mask = next_bitmask(old, elem.mask, elem_pair.second);
        auto ptr = elem.ptr;
        CPPA_LOG_DEBUG("new bitmask for "
                       << elem.ptr << ": " << eb2str(mask));
        if (iter == last || iter->fd != elem.fd) {
            CPPA_LOG_ERROR_IF(mask == event::none,
                              "cannot erase " << ptr << " (no such element)");
            if (mask != event::none) {
                m_meta.insert(iter, elem);
                handle_event(fd_meta_event::add, elem.fd,
                             event::none, mask, ptr);
            }
        }
        else if (iter->fd == elem.fd) {
            CPPA_REQUIRE(iter->ptr == elem.ptr);
            if (mask == event::none) {
                // note: we cannot decide whether it's safe to dispose `ptr`,
                // because we didn't parse all alterations yet
                m_dispose_list.emplace_back(ptr);
                m_meta.erase(iter);
                handle_event(fd_meta_event::erase, elem.fd, old, mask, ptr);
            }
            else {
                iter->mask = mask;
                handle_event(fd_meta_event::mod, elem.fd, old, mask, ptr);
            }
        }
    }
    m_alterations.clear();
    // m_meta won't be touched inside loop
    auto first = m_meta.begin();
    auto last = m_meta.end();
    auto is_alive = [&](native_socket_type fd) -> bool {
        auto iter = std::lower_bound(first, last, fd, mless);
        return iter != last && iter->fd == fd;
    };
    // check whether elements in dispose list can be safely deleted
    for (auto elem : m_dispose_list) {
        auto rd = elem->read_handle();
        auto wr = elem->write_handle();
        if  ( (rd == wr && !is_alive(rd))
           || (rd != wr && !is_alive(rd) && !is_alive(wr))) {
           elem->dispose();
        }
    }
    m_dispose_list.clear();
}
开发者ID:Zhouxiaoqing,项目名称:libcppa,代码行数:58,代码来源:middleman_event_handler.cpp


示例14: next

abstract_scheduled_actor::abstract_scheduled_actor(scheduler* sched)
    : next(nullptr)
    , m_state(ready)
    , m_scheduler(sched)
    , m_has_pending_timeout_request(false)
    , m_active_timeout_id(0)
{
    CPPA_REQUIRE(sched != nullptr);
}
开发者ID:nilo72,项目名称:libcppa,代码行数:9,代码来源:abstract_scheduled_actor.cpp


示例15: CPPA_REQUIRE

void binary_serializer::begin_object(const uniform_type_info* uti) {
    CPPA_REQUIRE(uti != nullptr);
    auto ot = outgoing_types();
    std::uint32_t id = (ot) ? ot->id_of(uti) : 0;
    std::uint8_t flag = (id == 0) ? 1 : 0;
    binary_writer::write_int(m_sink, flag);
    if (flag == 1) binary_writer::write_string(m_sink, uti->name());
    else binary_writer::write_int(m_sink, id);
}
开发者ID:ajac,项目名称:libcppa,代码行数:9,代码来源:binary_serializer.cpp


示例16: delayed_reply

 void delayed_reply(message_header hdr,
                    const Duration& rel_time,
                    any_tuple data           ) {
     CPPA_REQUIRE(hdr.id.valid() && hdr.id.is_response());
     auto tup = make_any_tuple(atom("SEND"),
                               util::duration{rel_time},
                               std::move(hdr),
                               std::move(data));
     m_timer->enqueue(message_header{}, std::move(tup), nullptr);
 }
开发者ID:ras0219,项目名称:libcppa,代码行数:10,代码来源:scheduler.hpp


示例17: CPPA_REQUIRE

bool actor::unlink_from_impl(const actor_ptr& other) {
    guard_type guard{m_mtx};
    // remove_backlink returns true if this actor is linked to other
    if (other && !exited() && other->remove_backlink(this)) {
        auto i = std::find(m_links.begin(), m_links.end(), other);
        CPPA_REQUIRE(i != m_links.end());
        m_links.erase(i);
        return true;
    }
    return false;
}
开发者ID:Zhouxiaoqing,项目名称:libcppa,代码行数:11,代码来源:actor.cpp


示例18: launch

 void launch(Actor* self, execution_unit*) {
     CPPA_REQUIRE(self != nullptr);
     CPPA_PUSH_AID(self->id());
     CPPA_LOG_TRACE(CPPA_ARG(self));
     intrusive_ptr<Actor> mself{self};
     self->attach_to_scheduler();
     std::thread([=] {
         CPPA_PUSH_AID(mself->id());
         CPPA_LOG_TRACE("");
         detail::cs_thread fself;
         for (;;) {
             if (mself->resume(&fself, nullptr) == resumable::done) {
                 return;
             }
             // await new data before resuming actor
             await_data(mself.get());
             CPPA_REQUIRE(self->mailbox().blocked() == false);
         }
         self->detach_from_scheduler();
     }).detach();
 }
开发者ID:ras0219,项目名称:libcppa,代码行数:21,代码来源:no_scheduling.hpp


示例19: timed_wait_for_data

 bool timed_wait_for_data(const timeout_type& abs_time) {
     CPPA_REQUIRE(not this->m_mailbox.closed());
     if (mailbox_empty()) {
         lock_type guard(m_mtx);
         while (mailbox_empty()) {
             if (m_cv.wait_until(guard, abs_time) == std::cv_status::timeout) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:Zhouxiaoqing,项目名称:libcppa,代码行数:12,代码来源:threaded.hpp


示例20: CPPA_REQUIRE

bool abstract_actor::unlink_from_impl(const actor_addr& other) {
    if (!other) return false;
    guard_type guard{m_mtx};
    // remove_backlink returns true if this actor is linked to other
    auto ptr = detail::raw_access::get(other);
    if (!exited() && ptr->remove_backlink(address())) {
        auto i = std::find(m_links.begin(), m_links.end(), ptr);
        CPPA_REQUIRE(i != m_links.end());
        m_links.erase(i);
        return true;
    }
    return false;
}
开发者ID:zoujiaqing,项目名称:libcppa,代码行数:13,代码来源:abstract_actor.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CPPUNIT_ASSERT函数代码示例发布时间:2022-05-30
下一篇:
C++ CPPAD_ASSERT_KNOWN函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap