A simple demonstration of using the event system.
#include <iostream>
#include <string>
#include <vector>
struct my_event_type;
{
public:
{}
virtual ~handler()
{
}
private:
{
}
void on_my_event(std::string const& s, std::vector<int> const& v)
{
std::cout << "Received event with text \"" << s << "\" and a vector with " << v.size() << " elements" << std::endl;
fz::scoped_lock lock(m);
}
};
int main()
{
handler h(l);
h.send_event<my_event>("Hello World!", std::vector<int>{23, 42, 666});
return 0;
}
Waitable condition variable.
Definition mutex.hpp:215
void wait(scoped_lock &l)
Wait indefinitely for condition to become signalled.
void signal(scoped_lock &l)
Signal condition variable.
Simple handler for asynchronous event processing.
Definition event_handler.hpp:55
void remove_handler()
Deactivates handler, removes all pending events and stops all timers for this handler.
virtual void operator()(event_base const &)=0
Called by the event loop in the worker thread with the event to process.
A threaded event loop that supports sending events and timers.
Definition event_loop.hpp:34
Lean replacement for std::(recursive_)mutex.
Definition mutex.hpp:57
A simple scoped lock.
Definition mutex.hpp:98
This is the recommended event class.
Definition event.hpp:68
Declares the event_handler class.
The namespace used by libfilezilla.
Definition apply.hpp:17
bool dispatch(event_base const &ev, F &&f)
Dispatch for simple_event<> based events to simple functors.
Definition event_handler.hpp:199