From: Davin McCall Date: Thu, 23 Jun 2016 22:38:27 +0000 (+0100) Subject: Latest Dasynq updates X-Git-Tag: v0.04~13 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6c430f5ce507a928df589e0008bcdcfe486da9ff;p=oweals%2Fdinit.git Latest Dasynq updates --- diff --git a/src/dasynq/dasynq-mutex.h b/src/dasynq/dasynq-mutex.h index a46c229..212e6e2 100644 --- a/src/dasynq/dasynq-mutex.h +++ b/src/dasynq/dasynq-mutex.h @@ -40,14 +40,8 @@ using DMutex = std::mutex; // A "null" mutex, for which locking / unlocking actually does nothing. class NullMutex { - #ifdef __GNUC__ - #ifndef __clang__ - char empty[0]; // Make class instances take up no space (gcc) - #else - char empty[0] __attribute__((unused)); // Make class instances take up no space (clang) - #endif - #endif - + EMPTY_BODY + public: void lock() { } void unlock() { } diff --git a/src/dasynq/dasynq.h b/src/dasynq/dasynq.h index b5a34b1..c457a40 100644 --- a/src/dasynq/dasynq.h +++ b/src/dasynq/dasynq.h @@ -35,9 +35,6 @@ namespace dasynq { #include #include -#include "dasynq-mutex.h" - - // TODO consider using atomic variables instead of explicit locking where appropriate @@ -45,17 +42,15 @@ namespace dasynq { // May be included as the last entry for a class which is only // _potentially_ empty. -/* #ifdef __GNUC__ -#ifdef __clang__ -#define EMPTY_BODY private: char empty_fill[0]; +#ifndef __clang__ +#define EMPTY_BODY char empty[0]; // Make class instances take up no space (gcc) #else -#define EMPTY_BODY private: char empty_fill[0]; +#define EMPTY_BODY char empty[0] __attribute__((unused)); // Make class instances take up no space (clang) #endif -#else -#define EMPTY_BODY #endif -*/ + +#include "dasynq-mutex.h" namespace dasynq { @@ -1080,6 +1075,11 @@ class FdWatcher : private dprivate::BaseFdWatcher eloop.registerFd(this, fd, flags, enabled); } + int getWatchedFd() + { + return this->watch_fd; + } + // Deregister a file descriptor watcher. // // If other threads may be polling the event loop, it is not safe to assume @@ -1125,7 +1125,7 @@ class BidiFdWatcher : private dprivate::BaseBidiFdWatcherwatch_flags &= ~events; } - if (LoopTraits::has_separate_rw_fd_watches) { + if (EventLoop::LoopTraits::has_separate_rw_fd_watches) { dprivate::BaseWatcher * watcher = in ? this : &this->outWatcher; eloop.setFdEnabled_nolock(watcher, this->watch_fd, events | ONE_SHOT, b); if (! b) { @@ -1145,8 +1145,6 @@ class BidiFdWatcher : private dprivate::BaseBidiFdWatcher guard(eloop.getBaseLock()); @@ -1196,6 +1195,11 @@ class BidiFdWatcher : private dprivate::BaseBidiFdWatcherwatch_fd; + } + // Deregister a bi-direction file descriptor watcher. // // If other threads may be polling the event loop, it is not safe to assume