/* * Copyright (c) 2010 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #pragma once #include #include #include #include #include #include namespace Swift { class EventOwner; class SWIFTEN_API EventLoop { public: EventLoop(); virtual ~EventLoop(); void postEvent(boost::function event, boost::shared_ptr owner = boost::shared_ptr()); void removeEventsFromOwner(boost::shared_ptr owner); protected: /** * Reimplement this to call handleEvent(event) from the thread in which * the event loop is residing. */ virtual void post(const Event& event) = 0; void handleEvent(const Event& event); private: boost::mutex eventsMutex_; unsigned int nextEventID_; std::list events_; bool handlingEvents_; std::deque eventsToHandle_; }; }