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