- updated MPESection creation
[senf.git] / Scheduler / Scheduler.cc
index 96aa9a2..6aa249c 100644 (file)
@@ -1,8 +1,8 @@
 // $Id$
 //
 // Copyright (C) 2006
-// Fraunhofer Institute for Open Communication Systems (FOKUS) 
-// Competence Center NETwork research (NET), St. Augustin, GERMANY 
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
 //     Stefan Bund <g0dil@berlios.de>
 //
 // This program is free software; you can redistribute it and/or modify
@@ -23,9 +23,6 @@
 /** \file
     \brief Scheduler non-inline non-template implementation
 
-    \idea Implement signal handling (See source for more discussion
-    about this)
-
     \idea Multithreading support: To support multithreading, the
     static member Scheduler::instance() must return a thread-local
     value (that is Scheduler::instance() must allocate one Scheduler
@@ -42,6 +39,7 @@
 //#include "Scheduler.ih"
 
 // Custom includes
+#include "../Utils/senfassert.hh"
 #include <errno.h>
 #include <sys/epoll.h>
 #include <unistd.h>
@@ -58,24 +56,24 @@ prefix_ senf::Scheduler::Scheduler()
       eventTime_(0), eventEarly_(ClockService::milliseconds(11)), eventAdjust_(0)
 {
     if (epollFd_<0)
-        throwErrno();
+        throw SystemException();
 
     if (::pipe(sigpipe_) < 0)
-        throwErrno();
+        throw SystemException();
 
     int flags (::fcntl(sigpipe_[1],F_GETFL));
     if (flags < 0) 
-        throwErrno();
+        throw SystemException();
     flags |= O_NONBLOCK;
     if (::fcntl(sigpipe_[1], F_SETFL, flags) < 0) 
-        throwErrno();
+        throw SystemException();
 
     ::epoll_event ev;
     ::memset(&ev, 0, sizeof(ev));
     ev.events = EV_READ;
     ev.data.fd = sigpipe_[0];
     if (::epoll_ctl(epollFd_, EPOLL_CTL_ADD, sigpipe_[0], &ev) < 0)
-        throwErrno();
+        throw SystemException();
 }
 
 prefix_ void senf::Scheduler::registerSignal(unsigned signal, SimpleCallback const & cb)
@@ -135,7 +133,7 @@ prefix_ void senf::Scheduler::do_add(int fd, FdCallback const & cb, int eventMas
             ++ files_;
         }
         else
-            throwErrno("::epoll_ctl()");
+            throw SystemException("::epoll_ctl()");
     }
 }
 
@@ -165,7 +163,7 @@ prefix_ void senf::Scheduler::do_remove(int fd, int eventMask)
     }
 
     if (! file && epoll_ctl(epollFd_, action, fd, &ev) < 0)
-        throwErrno("::epoll_ctl()");
+        throw SystemException("::epoll_ctl()");
     if (file)
         -- files_;
 }
@@ -181,7 +179,7 @@ prefix_ void senf::Scheduler::registerSigHandlers()
             if (signal == SIGCHLD)
                 sa.sa_flags |= SA_NOCLDSTOP;
             if (::sigaction(signal, &sa, 0) < 0)
-                throwErrno();
+                throw SystemException();
         }
     }
 }
@@ -254,7 +252,7 @@ prefix_ void senf::Scheduler::process()
 
         if (events<0)
             if (errno != EINTR)
-                throwErrno();
+                throw SystemException();
 
         eventTime_ = ClockService::now();
 
@@ -301,15 +299,15 @@ prefix_ void senf::Scheduler::process()
             if (mask & EPOLLERR) extraFlags |= EV_ERR;
 
             if (mask & EPOLLIN) {
-                BOOST_ASSERT(spec.cb_read);
+                SENF_ASSERT(spec.cb_read);
                 spec.cb_read(EventId(EV_READ | extraFlags));
             }
             else if (mask & EPOLLPRI) {
-                BOOST_ASSERT(spec.cb_prio);
+                SENF_ASSERT(spec.cb_prio);
                 spec.cb_prio(EventId(EV_PRIO | extraFlags));
             }
             else if (mask & EPOLLOUT) {
-                BOOST_ASSERT(spec.cb_write);
+                SENF_ASSERT(spec.cb_write);
                 spec.cb_write(EventId(EV_WRITE | extraFlags));
             }
             else {