]> Dogcows Code - chaz/yoink/blobdiff - src/moof/socket.hh
prep for runloop code
[chaz/yoink] / src / moof / socket.hh
index f4d2c82609e433d95cc8cc6ce2cf6429b291e2d7..08a5f50b1e88bec974ab9d1988d83eb10459a561 100644 (file)
 #include <string>
 #include <vector>
 
-#if HAVE_FCNTL_H
 #include <fcntl.h>
-#else
-#error No alternative to fcntl implemented yet.
-#endif
 
 #if defined(_WIN32)
 #include <winsock2.h>
@@ -44,7 +40,7 @@
 #include <sys/types.h>
 #endif
 
-#include <moof/log.hh>
+#include <moof/debug.hh>
 #include <moof/packet.hh>
 #include <moof/thread.hh>
 
@@ -733,13 +729,13 @@ public:
         */
        void is_blocking(bool is_blocking)
        {
-#ifdef HAVE_FCNTL
+#if defined(_WIN32)
+               u_long value = is_blocking;
+               ioctlsocket(impl_.fd, FIONBIO, &value);
+#else
                int flags = fcntl(impl_.fd, F_GETFL);
                flags = is_blocking ? (flags & ~O_NONBLOCK) : (flags | O_NONBLOCK);
                fcntl(impl_.fd, F_SETFL, flags);
-#elif defined(_WIN32)
-               u_long value = is_blocking;
-               ioctlsocket(impl_.fd, FIONBIO, &value);
 #endif
        }
 
@@ -751,11 +747,12 @@ public:
         */
        bool is_blocking() const
        {
-#ifdef HAVE_FCNTL
+#if defined(_WIN32)
+               return true;
+#else
                int flags = fcntl(impl_.fd, F_GETFL);
                return !(flags & O_NONBLOCK);
 #endif
-               return true;
        }
 
 
@@ -1005,7 +1002,7 @@ public:
 
        void socket(moof::socket sock)
        {
-               mutex::scoped_lock lock(mutex_);
+               MOOF_MUTEX_LOCK(mutex_);
                socket_ = sock;
        }
 
@@ -1049,7 +1046,8 @@ private:
 
        moof::socket                    socket_;
        std::vector<function>   protocols_;
-       mutex                                   mutex_;
+
+       MOOF_DECLARE_MUTEX(mutex_);
 };
 
 
This page took 0.021325 seconds and 4 git commands to generate.