Index: src/xplcommon/WaitableEvent.h
===================================================================
--- src/xplcommon/WaitableEvent.h	(revision 7)
+++ src/xplcommon/WaitableEvent.h	(revision 8)
@@ -44,9 +44,14 @@
  * An event on which one can wait with a waiter.
  */
-class WaitableEvent : public Waitable
+class WaitableEvent : public Waitable, public Failable
 {
 public:
     /**
      * Construct the event.
+     *
+     * @param waiter the waiter to be used for waiting. If given, the
+     * check() function will always return immediately. If not given,
+     * the check() function may block and returns only when the event
+     * is fired.
      */
     WaitableEvent(Waiter* waiter = 0);
Index: src/xplcommon/posix/WaitableEvent.cc
===================================================================
--- src/xplcommon/posix/WaitableEvent.cc	(revision 6)
+++ src/xplcommon/posix/WaitableEvent.cc	(revision 8)
@@ -48,5 +48,6 @@
 
 WaitableEvent::WaitableEvent(Waiter* waiter) :
-    Waitable(waiter, eventfd(0, EFD_NONBLOCK), POLLIN)
+    Waitable(waiter, eventfd(0, (waiter==0) ? 0 : EFD_NONBLOCK), POLLIN),
+    fired(false)
 {
     assert(fd>=0);
@@ -67,6 +68,5 @@
     if (write(fd, &one, sizeof(one))<0) {
         if (errno!=EAGAIN) {
-            perror("xplcommon::posix::WaitableEvent::fire: write");
-            assert(0);
+            setErrorCode(errno);
         }
     }
@@ -77,5 +77,5 @@
 bool WaitableEvent::check()
 {
-    if (fired) {
+    if (doCheck()) {
         fired = false;
         return true;
@@ -97,14 +97,25 @@
 {
     if ((events&POLLIN)==POLLIN) {
-        uint64_t value = 0;
-        if (read(fd, &value, sizeof(value))<0) {
-            if (errno!=EAGAIN) {
-                perror("xplcommon::posix::WaitableEvent::handleEvents: read");
-                assert(0);
-            }
-        } else {
-            fired = value>0;
+        doCheck();
+    }
+}
+
+//------------------------------------------------------------------------------
+
+bool WaitableEvent::doCheck(bool fromHandleEvents)
+{
+    if (failed()) return false;
+    if (!fromHandleEvents && fired) return true;
+
+    uint64_t value = 0;
+    if (read(fd, &value, sizeof(value))<0) {
+        if (errno!=EAGAIN) {
+            setErrorCode(errno);
         }
+    } else {
+        fired = fired || value>0;
     }
+
+    return fired;
 }
 
Index: src/xplcommon/posix/WaitableEvent.h
===================================================================
--- src/xplcommon/posix/WaitableEvent.h	(revision 6)
+++ src/xplcommon/posix/WaitableEvent.h	(revision 8)
@@ -34,4 +34,6 @@
 #include "Waitable.h"
 
+#include "../Failable.h"
+
 //------------------------------------------------------------------------------
 
@@ -43,5 +45,5 @@
  * An event on which one can wait with a waiter.
  */
-class WaitableEvent : public Waitable
+class WaitableEvent : public Waitable, public Failable
 {
 private:
@@ -83,4 +85,11 @@
      */
     virtual void handleEvents(short events);
+
+private:
+    /**
+     * Perform the real check. If we already know that we are fired,
+     * just return true. Otherwise try to read from the event fd.
+     */
+    bool doCheck(bool fromHandleEvents = false);
 };
 
Index: test/testevent.cc
===================================================================
--- test/testevent.cc	(revision 4)
+++ test/testevent.cc	(revision 8)
@@ -89,4 +89,39 @@
 //------------------------------------------------------------------------------
 
+class BlockingServerThread : public Thread
+{
+private:
+    WaitableEvent event;
+
+public:
+    WaitableEvent& getEvent();
+
+    virtual void run();
+};
+
+//------------------------------------------------------------------------------
+
+inline WaitableEvent& BlockingServerThread::getEvent()
+{
+    return event;
+}
+
+//------------------------------------------------------------------------------
+
+void BlockingServerThread::run()
+{
+    printf("BlockingServerThread::run: waiting...\n");
+    if (event.check()) {
+        printf("BlockingServerThread::run: waiting done\n");
+    } else {
+        printf("BlockingServerThread::run: waiting failed\n");
+    }
+    printf("BlockingServerThread::run: finished\n");
+}
+
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
 class ClientThread : public Thread
 {
@@ -120,7 +155,7 @@
 //------------------------------------------------------------------------------
 
-int main()
+template <class Server> void runTest()
 {
-    ServerThread serverThread;
+    Server serverThread;
     ClientThread clientThread(serverThread.getEvent());
 
@@ -134,4 +169,16 @@
     serverThread.join();
     printf("Both threads returned\n");
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+int main()
+{
+    printf("Running the event test with a non-blocking WaitableEvent\n\n");
+    runTest<ServerThread>();
+
+    printf("\n\nRunning the event test with a blocking WaitableEvent\n\n");
+    runTest<BlockingServerThread>();
 
     return 0;
