]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/pollable.cpp
Rename to libmspcore
[libs/core.git] / source / core / pollable.cpp
diff --git a/source/core/pollable.cpp b/source/core/pollable.cpp
new file mode 100644 (file)
index 0000000..4db38dd
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+This file is part of libmspframework
+Copyright © 2006 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+#ifdef WIN32
+#include <winsock2.h>
+#include "win32poll.h"
+#else
+#include <poll.h>
+#endif
+#include "pollable.h"
+
+namespace Msp {
+
+short Pollable::poll(short events, int timeout)
+{
+#ifdef WIN32
+       return 0;
+#else
+       pollfd pfd={get_fd(), events, 0};
+       int result=::poll(&pfd, 1, timeout);
+       if(result<=0)
+               return result;
+       return pfd.revents;
+#endif
+}
+
+}