diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-07-15 07:42:18 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-07-15 07:42:18 (GMT) |
commit | 0930cd940963be0edfe7c80b4925babca0e01443 (patch) | |
tree | b2a57761bfdf1a14ea75ea1a9871c70d85ff8024 /Swiften/EventLoop/EventLoop.h | |
parent | d2625df30861a4caa984031a6990d19dfebc3367 (diff) | |
download | swift-0930cd940963be0edfe7c80b4925babca0e01443.zip swift-0930cd940963be0edfe7c80b4925babca0e01443.tar.bz2 |
Use shared_ptr for EventLoop owners.
Diffstat (limited to 'Swiften/EventLoop/EventLoop.h')
-rw-r--r-- | Swiften/EventLoop/EventLoop.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Swiften/EventLoop/EventLoop.h b/Swiften/EventLoop/EventLoop.h index 2f04f32..bf6f929 100644 --- a/Swiften/EventLoop/EventLoop.h +++ b/Swiften/EventLoop/EventLoop.h @@ -1,22 +1,22 @@ -#ifndef SWIFTEN_EventLoop_H -#define SWIFTEN_EventLoop_H +#pragma once #include <boost/function.hpp> #include <boost/thread/mutex.hpp> #include <list> namespace Swift { + class EventOwner; class EventLoop { public: EventLoop(); virtual ~EventLoop(); - void postEvent(boost::function<void ()> event, void* owner); - void removeEventsFromOwner(void* owner); + void postEvent(boost::function<void ()> event, boost::shared_ptr<EventOwner> owner = boost::shared_ptr<EventOwner>()); + void removeEventsFromOwner(boost::shared_ptr<EventOwner> owner); protected: struct Event { - Event(void* owner, const boost::function<void()>& callback) : + Event(boost::shared_ptr<EventOwner> owner, const boost::function<void()>& callback) : owner(owner), callback(callback) { } @@ -25,7 +25,7 @@ namespace Swift { } unsigned int id; - void* owner; + boost::shared_ptr<EventOwner> owner; boost::function<void()> callback; }; @@ -39,14 +39,12 @@ namespace Swift { private: struct HasOwner { - HasOwner(void* owner) : owner(owner) {} + HasOwner(boost::shared_ptr<EventOwner> owner) : owner(owner) {} bool operator()(const Event& event) { return event.owner == owner; } - void* owner; + boost::shared_ptr<EventOwner> owner; }; boost::mutex eventsMutex_; unsigned int nextEventID_; std::list<Event> events_; }; } - -#endif |