Changeset 6:81a0ade149e1 in xplcommon


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

Implemented basic POSIX socket infrastructure

Location:
src/xplcommon
Files:
19 added
5 edited

Legend:

Unmodified
Added
Removed
  • src/xplcommon/Makefile.am

    r5 r6  
    2323include_xplcommon_HEADERS=\
    2424        config.h        \
     25        types.h         \
     26        Failable.h      \
    2527        Thread.h        \
    2628        Waiter.h        \
  • src/xplcommon/posix/Makefile.am

    r4 r6  
    33libxplcommon_posix_la_SOURCES = \
    44        Thread.cc               \
    5         Waitable.cc     \
    6         Waiter.cc       \
    7         WaitableEvent.cc
     5        Waitable.cc             \
     6        Waiter.cc               \
     7        WaitableEvent.cc        \
     8        ReadingBuffer.cc        \
     9        WritingBuffer.cc        \
     10        BufferedWaitable.cc     \
     11        Acceptor.cc             \
     12        ServerSocket.cc         \
     13        Socket.cc               \
     14        Connector.cc            \
     15        ClientSocket.cc
    816
    917include_xplcommon_posixdir=$(includedir)/xplcommon/posix
     
    1220        Waitable.h              \
    1321        Waiter.h                \
    14         WaitableEvent.h
     22        WaitableEvent.h         \
     23        WaitableBuffer.h        \
     24        ReadingBuffer.h         \
     25        WritingBuffer.h         \
     26        BufferedWaitable.h      \
     27        Acceptor.h              \
     28        ServerSocket.h          \
     29        Socket.h                \
     30        Connector.h             \
     31        ClientSocket.h
  • 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//------------------------------------------------------------------------------
  • src/xplcommon/posix/WaitableEvent.cc

    r4 r6  
    6262//------------------------------------------------------------------------------
    6363
    64 bool WaitableEvent::ready()
    65 {
    66     return fired;
    67 }
    68 
    69 //------------------------------------------------------------------------------
    70 
    7164void WaitableEvent::fire()
    7265{
     
    9083        return false;
    9184    }
     85}
     86
     87//------------------------------------------------------------------------------
     88
     89bool WaitableEvent::isReady()
     90{
     91    return fired;
    9292}
    9393
  • src/xplcommon/posix/WaitableEvent.h

    r4 r6  
    6363
    6464    /**
    65      * Check if the event is fired or not.
    66      */
    67     virtual bool ready();
    68 
    69     /**
    7065     * Fire the event.
    7166     */
     
    7974
    8075protected:
     76    /**
     77     * Check if the event is fired or not.
     78     */
     79    virtual bool isReady();
     80
    8181    /**
    8282     * Handle the given events.
Note: See TracChangeset for help on using the changeset viewer.