// // mp::event // // Copyright (C) 2008 FURUHASHI Sadayuki // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #ifndef MP_EVENT_H__ #define MP_EVENT_H__ #include "mp/system/config.h" #include "mp/exception.h" #include "mp/utility.h" #include "mp/sparse_array.h" namespace mp { template class event { public: typedef Data data_t; public: inline event(); inline ~event(); inline int add(int fd, short event); MP_ARGS_BEGIN template inline int add(int fd, short event, MP_ARGS_PARAMS); MP_ARGS_END inline int remove(int fd, short oldevent); inline int modify(int fd, short oldevent, short newevent); inline int wait(); inline int wait(int timeout_msec); inline bool next(int* fd, short* revent); inline bool next(int* fd, short* revent, data_t** data); inline bool test(int fd); inline data_t& data(int fd); inline const data_t& data(int fd) const; private: system m_system; sparse_array m_events; private: event(const event&); }; template <> class event { public: typedef void data_t; public: inline event(); inline ~event(); inline int add(int fd, short event); inline int remove(int fd, short oldevent); inline int modify(int fd, short oldevent, short newevent); inline int wait(); inline int wait(int timeout_msec); inline bool next(int* fd, short* revent); private: system m_system; private: event(const event&); }; } // namespace mp #include "mp/event_impl.h" #endif /* mp/event.h */