Commit 66190667 authored by neverlord's avatar neverlord

removed obsolete matcher_arguments

parent 9524070a
......@@ -35,7 +35,6 @@ libcppa_la_SOURCES = \
src/invokable.cpp \
src/invoke_rules.cpp \
src/mailman.cpp \
src/matcher_arguments.cpp \
src/message_queue.cpp \
src/mock_scheduler.cpp \
src/native_socket.cpp \
......@@ -109,7 +108,6 @@ nobase_library_include_HEADERS = \
cppa/detail/list_member.hpp \
cppa/detail/mailman.hpp \
cppa/detail/map_member.hpp \
cppa/detail/matcher_arguments.hpp \
cppa/detail/mock_scheduler.hpp \
cppa/detail/native_socket.hpp \
cppa/detail/network_manager.hpp \
......
#ifndef MATCHER_ARGUMENTS_HPP
#define MATCHER_ARGUMENTS_HPP
#include <vector>
#include "cppa/util/any_tuple_iterator.hpp"
namespace cppa { namespace detail {
struct matcher_arguments
{
util::any_tuple_iterator iter;
std::vector<size_t>* mapping;
matcher_arguments(const any_tuple& tup, std::vector<size_t>* mv = nullptr);
matcher_arguments(util::any_tuple_iterator tuple_iterator,
std::vector<size_t>* mv = nullptr);
matcher_arguments(const matcher_arguments&) = default;
matcher_arguments& operator=(const matcher_arguments&) = default;
inline bool at_end() const;
inline matcher_arguments& next();
inline bool push_mapping();
};
inline bool matcher_arguments::at_end() const
{
return iter.at_end();
}
inline matcher_arguments& matcher_arguments::next()
{
iter.next();
return *this;
}
inline bool matcher_arguments::push_mapping()
{
if (mapping) mapping->push_back(iter.position());
return true;
}
} } // namespace cppa::detail
#endif // MATCHER_ARGUMENTS_HPP
......@@ -187,57 +187,70 @@ struct tuple_iterator_arg
template<typename VectorType>
bool do_match(pattern_arg& pargs, tuple_iterator_arg<VectorType>& targs)
{
if (pargs.at_end() && targs.at_end())
for (;;)
{
return true;
}
if (pargs.type() == nullptr) // nullptr == wildcard
{
// perform submatching
pargs.next();
if (pargs.at_end())
if (pargs.at_end() && targs.at_end())
{
// always true at the end of the pattern
return true;
}
auto pargs_copy = pargs;
VectorType mv;
auto mv_ptr = (targs.mapping) ? &mv : nullptr;
// iterate over tu_args until we found a match
while (targs.at_end() == false)
else if (pargs.type() == nullptr) // nullptr == wildcard (anything)
{
tuple_iterator_arg<VectorType> targs_copy(targs.iter, mv_ptr);
if (do_match(pargs_copy, targs_copy))
// perform submatching
pargs.next();
if (pargs.at_end())
{
if (mv_ptr)
// always true at the end of the pattern
return true;
}
auto pargs_copy = pargs;
VectorType mv;
auto mv_ptr = (targs.mapping) ? &mv : nullptr;
// iterate over tu_args until we found a match
while (targs.at_end() == false)
{
tuple_iterator_arg<VectorType> targs_copy(targs.iter, mv_ptr);
if (do_match(pargs_copy, targs_copy))
{
targs.mapping->insert(targs.mapping->end(),
mv.begin(),
mv.end());
if (mv_ptr)
{
targs.mapping->insert(targs.mapping->end(),
mv.begin(),
mv.end());
}
return true;
}
return true;
// next iteration
mv.clear();
targs.next();
}
// next iteration
mv.clear();
targs.next();
// no successfull submatch found
return false;
}
}
else
{
// compare types
if (targs.at_end() == false && pargs.type() == targs.type())
else if (targs.at_end() == false && pargs.type() == targs.type())
{
// compare values if needed
if ( pargs.has_value() == false
|| pargs.type()->equal(pargs.value(), targs.value()))
{
targs.push_mapping();
// submatch
return do_match(pargs.next(), targs.next());
// ok, go to next iteration
}
else
{
// values didn't match
return false;
}
}
else
{
// no match
return false;
}
// next iteration
pargs.next();
targs.next();
}
return false;
}
} } // namespace cppa::detail
......
#include "cppa/detail/matcher_arguments.hpp"
namespace cppa { namespace detail {
matcher_arguments::matcher_arguments(util::any_tuple_iterator tuple_iterator,
std::vector<size_t>* mv)
: iter(tuple_iterator), mapping(mv)
{
}
matcher_arguments::matcher_arguments(const any_tuple& tup,
std::vector<size_t>* mv)
: iter(tup), mapping(mv)
{
}
} } // namespace cppa::detail
......@@ -170,7 +170,9 @@ bool yielding_message_queue_impl::dequeue_impl(any_tuple& storage)
// dequeue next message
return false;
}
storage = std::move(node->msg);
m_last_dequeued = std::move(node->msg);
m_last_sender = std::move(node->sender);
storage = m_last_dequeued;
return true;
}
......@@ -194,7 +196,8 @@ yielding_message_queue_impl::dq(std::unique_ptr<queue_node>& node,
auto imd = rules.get_intermediate(node->msg);
if (imd)
{
m_last_dequeued = node->msg;
m_last_dequeued = std::move(node->msg);
m_last_sender = std::move(node->sender);
// restore mailbox before invoking imd
if (!buffer.empty()) m_queue.push_front(std::move(buffer));
imd->invoke();
......@@ -221,6 +224,7 @@ bool yielding_message_queue_impl::dequeue_impl(timed_invoke_rules& rules,
switch (dq(node, rules, buffer))
{
case done:
{
if (m_has_pending_timeout_request)
{
// expire pending request
......@@ -228,14 +232,14 @@ bool yielding_message_queue_impl::dequeue_impl(timed_invoke_rules& rules,
m_has_pending_timeout_request = false;
}
return true;
}
case timeout_occured:
rules.handle_timeout();
{
m_has_pending_timeout_request = false;
rules.handle_timeout();
return true;
case indeterminate:
return false;
}
default: break;
}
return false;
}
......
......@@ -29,7 +29,6 @@
// header for experimental stuff
#include "cppa/util/filter_type_list.hpp"
#include "cppa/util/any_tuple_iterator.hpp"
#include "cppa/detail/matcher_arguments.hpp"
#define CPPA_TEST_CATCH_BLOCK() \
catch (std::exception& e) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment