Commit b06c4e27 authored by Max Kellermann's avatar Max Kellermann

event/{Idle,Defer}Event: use base_hook instead of member_hook

Allows forward declaration.
parent 1686f4e8
...@@ -31,12 +31,11 @@ class EventLoop; ...@@ -31,12 +31,11 @@ class EventLoop;
* *
* This class is thread-safe. * This class is thread-safe.
*/ */
class DeferEvent final { class DeferEvent final
: public boost::intrusive::list_base_hook<>
{
friend class EventLoop; friend class EventLoop;
typedef boost::intrusive::list_member_hook<> ListHook;
ListHook list_hook;
EventLoop &loop; EventLoop &loop;
typedef BoundMethod<void() noexcept> Callback; typedef BoundMethod<void() noexcept> Callback;
...@@ -59,7 +58,7 @@ public: ...@@ -59,7 +58,7 @@ public:
private: private:
bool IsPending() const noexcept { bool IsPending() const noexcept {
return list_hook.is_linked(); return is_linked();
} }
void RunDeferred() noexcept { void RunDeferred() noexcept {
......
...@@ -34,12 +34,11 @@ class EventLoop; ...@@ -34,12 +34,11 @@ class EventLoop;
* thread that runs the #EventLoop, except where explicitly documented * thread that runs the #EventLoop, except where explicitly documented
* as thread-safe. * as thread-safe.
*/ */
class IdleEvent { class IdleEvent
: public boost::intrusive::list_base_hook<>
{
friend class EventLoop; friend class EventLoop;
using ListHook = boost::intrusive::list_member_hook<>;
ListHook list_hook;
EventLoop &loop; EventLoop &loop;
using Callback = BoundMethod<void() noexcept>; using Callback = BoundMethod<void() noexcept>;
...@@ -63,7 +62,7 @@ public: ...@@ -63,7 +62,7 @@ public:
} }
bool IsActive() const noexcept { bool IsActive() const noexcept {
return list_hook.is_linked(); return is_linked();
} }
void Schedule() noexcept; void Schedule() noexcept;
......
...@@ -72,9 +72,7 @@ class EventLoop final : SocketMonitor ...@@ -72,9 +72,7 @@ class EventLoop final : SocketMonitor
using IdleList = using IdleList =
boost::intrusive::list<IdleEvent, boost::intrusive::list<IdleEvent,
boost::intrusive::member_hook<IdleEvent, boost::intrusive::base_hook<boost::intrusive::list_base_hook<>>,
IdleEvent::ListHook,
&IdleEvent::list_hook>,
boost::intrusive::constant_time_size<false>>; boost::intrusive::constant_time_size<false>>;
IdleList idle; IdleList idle;
...@@ -82,9 +80,7 @@ class EventLoop final : SocketMonitor ...@@ -82,9 +80,7 @@ class EventLoop final : SocketMonitor
using DeferredList = using DeferredList =
boost::intrusive::list<DeferEvent, boost::intrusive::list<DeferEvent,
boost::intrusive::member_hook<DeferEvent, boost::intrusive::base_hook<boost::intrusive::list_base_hook<>>,
DeferEvent::ListHook,
&DeferEvent::list_hook>,
boost::intrusive::constant_time_size<false>>; boost::intrusive::constant_time_size<false>>;
DeferredList deferred; DeferredList deferred;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment