00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef header_event
00030 #define header_event
00031
00032 #include "mutex.h"
00033 #include "socket_event_handler.h"
00034 #include <vector>
00035
00036 class CL_Event
00037 {
00039 public:
00040 enum EventType
00041 {
00042 type_native,
00043 type_socket_read,
00044 type_socket_write,
00045 type_socket_exception
00046 };
00047
00048 CL_Event(bool manual_reset = false, bool initial_state = false);
00049
00050 CL_Event(CL_SocketEventHandler *socket_handler, EventType type);
00051
00052 ~CL_Event();
00053
00055 public:
00056
00058 public:
00059 bool wait(int timeout = -1) const;
00060
00061 static int wait(int count, CL_Event const * const * events, int timeout = -1, bool wait_all = false);
00062
00063 static int wait(const std::vector<CL_Event *> &events, int timeout = -1, bool wait_all = false);
00064
00065 void set();
00066
00067 void reset();
00068
00070 private:
00071 CL_Event(const CL_Event ©);
00072
00073 CL_Event &operator =(const CL_Event ©);
00074
00075 #ifdef WIN32
00076 HANDLE handle;
00077 #else
00078 mutable CL_Mutex mutex;
00079
00080 bool manual_reset;
00081
00082 mutable bool state;
00083
00084 int wait_sockets[2];
00085 #endif
00086 EventType type;
00087
00088 CL_SocketEventHandler *socket_handler;
00089 };
00090
00091 #endif