Changeset 6:81a0ade149e1 in xplcommon for src/xplcommon/posix/Waitable.h


Ignore:
Timestamp:
12/29/12 06:40:32 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Implemented basic POSIX socket infrastructure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/xplcommon/posix/Waitable.h

    r4 r6  
    8282
    8383    /**
     84     * Indicate if this waitable is valid, i.e. the file descriptor is
     85     * non-negative.
     86     */
     87    bool isValid() const;
     88
     89    /**
     90     * Determine if the waitable is ready or not, i.e. if there is no
     91     * need to wait for it.
     92     *
     93     * It first checks the events. If they are 0, the waitable is
     94     * ready. Then it calls isReady() and returns the result of that
     95     * function.
     96     */
     97    bool ready();
     98
     99protected:
     100    /**
    84101     * Indicate if the waitable is ready, i.e. there is no need to
    85102     * wait for it.
    86103     *
    87      * Calling this function should not deleted the ready
    88      * indication. It should be deleted by actually processing the data.
     104     * Calling this function should not delete the ready
     105     * indication. It should be deleted by actually processing the
     106     * data.
    89107     */
    90     virtual bool ready() = 0;
     108    virtual bool isReady() = 0;
    91109
    92 protected:
    93110    /**
    94111     * Handle the given events.
     
    98115    friend class Waiter;
    99116};
     117
     118//------------------------------------------------------------------------------
     119// Inline defintions
     120//------------------------------------------------------------------------------
     121
     122inline bool Waitable::isValid() const
     123{
     124    return fd>=0;
     125}
     126
     127//------------------------------------------------------------------------------
     128
     129inline bool Waitable::ready()
     130{
     131    return (events==0) || isReady();
     132}
    100133
    101134//------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.