#include "sync.hpp"

namespace fz {

bool sync_receiver_maker::receiver_base::run(duration timeout)
{
	if (timeout) {
		add_timer(timeout, true);
	}

	scoped_lock l(m_);
	c_.wait(l);

	return has_timed_out_;
}

sync_receiver_maker::receiver_base::receiver_base()
	: event_handler(get_loop())
{}

sync_receiver_maker::receiver_base::~receiver_base() = default;

event_loop &sync_receiver_maker::receiver_base::get_loop()
{
	static event_loop loop;
	return loop;
}

}
