Changeset 3:e4ca2e057cec in xplcommon for src/xplcommon/posix/Waiter.cc


Ignore:
Timestamp:
12/27/12 13:01:22 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Reorganized the code a bit

File:
1 moved

Legend:

Unmodified
Added
Removed
  • src/xplcommon/posix/Waiter.cc

    r1 r3  
    3030//------------------------------------------------------------------------------
    3131
    32 #include "config.h"
    33 #ifdef HAVE_POLL_H
     32#include "Waiter.h"
    3433
    35 //------------------------------------------------------------------------------
    36 
    37 #include "POSIXWaiter.h"
    38 #include "POSIXWaitable.h"
     34#include "Waitable.h"
    3935
    4036#include <cassert>
     
    4339//------------------------------------------------------------------------------
    4440
    45 using xplcommon::POSIXWaiter;
     41using xplcommon::posix::Waiter;
    4642
    4743//------------------------------------------------------------------------------
    4844
    49 inline bool POSIXWaiter::hasReady() const
     45inline bool Waiter::hasReady() const
    5046{
    5147    for(waitables_t::const_iterator i = waitables.begin(); i!=waitables.end();
    5248        ++i)
    5349    {
    54         POSIXWaitable* waitable = i->second;
     50        Waitable* waitable = i->second;
    5551        if (waitable->ready()) return true;
    5652    }
     
    6056//------------------------------------------------------------------------------
    6157
    62 inline size_t POSIXWaiter::setupPollFDs(pollfd* pollFDs)
     58inline size_t Waiter::setupPollFDs(pollfd* pollFDs)
    6359{
    6460    size_t numValid = 0;
     
    6763        ++i)
    6864    {
    69         POSIXWaitable* waitable = i->second;
     65        Waitable* waitable = i->second;
    7066        if (waitable->events==0) continue;
    7167
     
    8278//------------------------------------------------------------------------------
    8379
    84 inline void POSIXWaiter::processPollFDs(const pollfd* pollFDs, size_t size)
     80inline void Waiter::processPollFDs(const pollfd* pollFDs, size_t size)
    8581{
    8682    for(size_t i = 0; i<size; ++i) {
     
    8985            waitables_t::iterator j = waitables.find(pollFD.fd);
    9086            assert(j!=waitables.end());
    91             POSIXWaitable* waitable = j->second;
     87            Waitable* waitable = j->second;
    9288            waitable->handleEvents(pollFD.revents);
    9389        }
     
    9793//------------------------------------------------------------------------------
    9894
    99 POSIXWaiter::~POSIXWaiter()
     95Waiter::~Waiter()
    10096{
    10197    for(waitables_t::iterator i = waitables.begin(); i!=waitables.end(); ++i)
    10298    {
    103         POSIXWaitable* waitable = i->second;
     99        Waitable* waitable = i->second;
    104100        waitable->waiter = 0;
    105101    }
     
    108104//------------------------------------------------------------------------------
    109105
    110 bool POSIXWaiter::wait(int timeout)
     106bool Waiter::wait(int timeout)
    111107{
    112108    if (hasReady()) return true;
     
    118114
    119115    if (result<0) {
    120         perror("POSIXWaiter::wait: poll");
     116        perror("xplcommon::posix::Waiter::wait: poll");
    121117        return false;
    122118    } else if (result>0) {
     
    129125//------------------------------------------------------------------------------
    130126
    131 void POSIXWaiter::add(POSIXWaitable* waitable)
     127void Waiter::add(Waitable* waitable)
    132128{
    133129    assert(waitable->fd>=0);
     
    139135//------------------------------------------------------------------------------
    140136
    141 void POSIXWaiter::remove(POSIXWaitable* waitable)
     137void Waiter::remove(Waitable* waitable)
    142138{
    143139    assert(numWaitables>0);
     
    150146
    151147//------------------------------------------------------------------------------
    152 #endif // HAVE_POLL_H
    153148
    154149// Local Variables:
Note: See TracChangeset for help on using the changeset viewer.