X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fpoll.h;fp=source%2Fpoll.h;h=0000000000000000000000000000000000000000;hp=6367d8f2b301544f26953220284868d7658b22fb;hb=6e0fd758970bcb5bad5e3f2454b694cc4d7b4b66;hpb=b97d4e9f86e90254ab9edef7ee62a910f6333c78 diff --git a/source/poll.h b/source/poll.h deleted file mode 100644 index 6367d8f..0000000 --- a/source/poll.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef MSP_IO_POLL_H_ -#define MSP_IO_POLL_H_ - -#ifndef WIN32 -#include -#endif -#include -#include -#include -#include -#include "types.h" - -namespace Msp { -namespace IO { - -class Base; - -enum PollEvent -{ - P_NONE = 0, - P_INPUT = 1, - P_PRIO = 2, - P_OUTPUT = 4, - P_ERROR = 8 -}; - -inline PollEvent operator|(PollEvent e, PollEvent f) -{ return PollEvent(static_cast(e)|static_cast(f)); } - -inline PollEvent operator&(PollEvent e, PollEvent f) -{ return PollEvent(static_cast(e)&static_cast(f)); } - -inline PollEvent operator~(PollEvent e) -{ return PollEvent(~static_cast(e)); } - - -class Poller -{ -public: - struct Slot - { - Base *object; - PollEvent events; - - Slot(Base *o, PollEvent e): object(o), events(e) { } - }; - - typedef std::list SlotSeq; -private: - typedef std::map SlotMap; - -#ifdef WIN32 - struct pollfd - { - Handle fd; - }; -#endif - - SlotMap objects; - std::vector pfd; - bool pfd_dirty; - SlotSeq poll_result; - - void rebuild_pfd(); - int do_poll(int); - -public: - Poller(); - - void set_object(Base &, PollEvent); - int poll(); - int poll(const Time::TimeDelta &); - const SlotSeq &get_result() const { return poll_result; } -}; - -PollEvent poll(Base &, PollEvent); -PollEvent poll(Base &, PollEvent, const Time::TimeDelta &); - -} // namespace IO -} // namespace Msp - -#endif