Run clang-format

This commit is contained in:
Bassem Girgis
2018-10-18 00:40:34 -05:00
parent fffe4528da
commit 31c32e368a
149 changed files with 5974 additions and 6287 deletions

View File

@@ -1,65 +1,53 @@
namespace messaging
{
class close_queue
{};
namespace messaging {
class close_queue {
};
class dispatcher
{
queue* q;
bool chained;
class dispatcher {
queue* q;
bool chained;
dispatcher(dispatcher const&)=delete;
dispatcher& operator=(dispatcher const&)=delete;
dispatcher(dispatcher const&) = delete;
dispatcher& operator=(dispatcher const&) = delete;
template<
typename Dispatcher,
typename Msg,
typename Func>
friend class TemplateDispatcher;
template <typename Dispatcher, typename Msg, typename Func>
friend class TemplateDispatcher;
void wait_and_dispatch()
{
for(;;)
{
auto msg=q->wait_and_pop();
dispatch(msg);
}
}
void wait_and_dispatch()
{
for (;;) {
auto msg = q->wait_and_pop();
dispatch(msg);
}
}
bool dispatch(
std::shared_ptr<message_base> const& msg)
{
if(dynamic_cast<wrapped_message<close_queue>*>(msg.get()))
{
throw close_queue();
}
return false;
}
public:
dispatcher(dispatcher&& other):
q(other.q),chained(other.chained)
{
other.chained=true;
}
bool dispatch(std::shared_ptr<message_base> const& msg)
{
if (dynamic_cast<wrapped_message<close_queue>*>(msg.get())) {
throw close_queue();
}
return false;
}
explicit dispatcher(queue* q_):
q(q_),chained(false)
{}
public:
dispatcher(dispatcher&& other) : q(other.q), chained(other.chained)
{
other.chained = true;
}
template<typename Message,typename Func>
TemplateDispatcher<dispatcher,Message,Func>
handle(Func&& f)
{
return TemplateDispatcher<dispatcher,Message,Func>(
q,this,std::forward<Func>(f));
}
explicit dispatcher(queue* q_) : q(q_), chained(false) {}
~dispatcher() noexcept(false)
{
if(!chained)
{
wait_and_dispatch();
}
}
};
}
template <typename Message, typename Func>
TemplateDispatcher<dispatcher, Message, Func> handle(Func&& f)
{
return TemplateDispatcher<dispatcher, Message, Func>(
q, this, std::forward<Func>(f));
}
~dispatcher() noexcept(false)
{
if (!chained) {
wait_and_dispatch();
}
}
};
} // namespace messaging