Changeset 21:eb59943050c9 in xplcommon for src/xplcommon/win32/Event.h


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

Added the implementation of the local sockets for Win32 and it seems to work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/xplcommon/win32/Event.h

    r20 r21  
    3232//------------------------------------------------------------------------------
    3333
    34 #include "../Failable.h"
     34#include "EventFailable.h"
    3535
    3636#include <windows.h>
     
    4949 * Wrapper for an event.
    5050 */
    51 class Event : public ::xplcommon::Failable
     51class Event
    5252{
    5353private:
    5454    /**
     55     * The object receiving the failure codes.
     56     */
     57    EventFailable& eventFailable;
     58
     59    /**
    5560     * The handle of the event.
    5661     */
     
    6671     * Construct the event.
    6772     */
    68     Event();
     73    Event(EventFailable& eventFailable);
    6974
    7075    /**
     
    96101
    97102    /**
     103     * Determine if the event is being waited for, i.e. it is
     104     * associated with a waiter.
     105     */
     106    bool isWaited() const;
     107
     108    /**
    98109     * Set the event.
    99110     */
    100111    void fire();
     112
     113    /**
     114     * Determine if the event is fired or not.
     115     */
     116    bool isFired() const;
    101117
    102118    /**
     
    106122     */
    107123    bool clear();
     124
     125protected:
     126    /**
     127     * Set the error code on the failable object.
     128     */
     129    void setErrorCode(errorCode_t errorCode);
    108130};
    109131
     
    112134//------------------------------------------------------------------------------
    113135
    114 inline Event::Event() :
     136inline Event::Event(EventFailable& eventFailable) :
     137    eventFailable(eventFailable),
    115138    handle(CreateEvent(0, true, false, 0)),
    116139    waiter(0)
    117140{
    118     if (handle==0) setErrorCode(GetLastError());
     141    if (handle==0) eventFailable.setErrorCode(GetLastError());
    119142}
    120143
     
    143166//------------------------------------------------------------------------------
    144167
     168inline bool Event::isWaited() const
     169{
     170    return waiter!=0;
     171}
     172
     173//------------------------------------------------------------------------------
     174
    145175inline void Event::fire()
    146176{
    147177    if (!SetEvent(handle)) {
    148         setErrorCode(GetLastError());
     178        eventFailable.setErrorCode(GetLastError());
    149179    }
    150180}
     
    155185{
    156186    if (!ResetEvent(handle)) {
    157         setErrorCode(GetLastError());
     187        eventFailable.setErrorCode(GetLastError());
    158188        return false;
    159189    } else {
    160190        return true;
    161191    }
     192}
     193
     194//------------------------------------------------------------------------------
     195
     196inline void Event::setErrorCode(errorCode_t errorCode)
     197{
     198    eventFailable.setErrorCode(errorCode);
    162199}
    163200
Note: See TracChangeset for help on using the changeset viewer.