Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Poller.cti

Go to the documentation of this file.
00001 // $Id: Poller.cti 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2008
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 //#include "Poller.ih"
00027 
00028 // Custom includes
00029 #include <unistd.h>
00030 
00031 #define prefix_ inline
00032 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00033 
00034 template <class Value>
00035 prefix_ senf::scheduler::detail::Poller<Value>::Poller()
00036     : timeout_ (-1)
00037 {
00038     epollFd_ = epoll_create(NumEvents);
00039     if (epollFd_ == -1)
00040         throw senf::SystemException("epoll_create");
00041 }
00042 
00043 template <class Value>
00044 prefix_ senf::scheduler::detail::Poller<Value>::~Poller()
00045 {
00046     close(epollFd_);
00047 }
00048 
00049 template <class Value>
00050 prefix_ void senf::scheduler::detail::Poller<Value>::timeout(int t)
00051 {
00052     timeout_ = t;
00053 }
00054 
00055 template <class Value>
00056 prefix_ int senf::scheduler::detail::Poller<Value>::timeout()
00057     const
00058 {
00059     return timeout_;
00060 }
00061 
00062 template <class Value>
00063 prefix_ typename senf::scheduler::detail::Poller<Value>::GetPollResult::result_type
00064 senf::scheduler::detail::Poller<Value>::GetPollResult::operator()(epoll_event const & ev)
00065     const
00066 
00067 {
00068     return std::make_pair(ev.events, static_cast<Value*>(ev.data.ptr));
00069 }
00070 
00071 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00072 #undef prefix_
00073 
00074 
00075 // Local Variables:
00076 // mode: c++
00077 // fill-column: 100
00078 // comment-column: 40
00079 // c-file-style: "senf"
00080 // indent-tabs-mode: nil
00081 // ispell-local-dictionary: "american"
00082 // compile-command: "scons -u test"
00083 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research