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

Allows forward declaration.
This commit is contained in:
Max Kellermann 2020-10-14 14:02:11 +02:00
parent 1686f4e857
commit b06c4e2711
3 changed files with 10 additions and 16 deletions

View File

@ -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:
private: private:
bool IsPending() const noexcept { bool IsPending() const noexcept {
return list_hook.is_linked(); return is_linked();
} }
void RunDeferred() noexcept { void RunDeferred() noexcept {

View File

@ -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:
} }
bool IsActive() const noexcept { bool IsActive() const noexcept {
return list_hook.is_linked(); return is_linked();
} }
void Schedule() noexcept; void Schedule() noexcept;

View File

@ -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
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;