diff --git a/src/condition_variable.hpp b/src/condition_variable.hpp index 11f4a0f4..d8c80953 100644 --- a/src/condition_variable.hpp +++ b/src/condition_variable.hpp @@ -81,9 +81,15 @@ namespace zmq #else +#ifdef ZMQ_HAVE_WINDOWS_TARGET_XP +#include +#include +#endif + namespace zmq { +#ifndef ZMQ_HAVE_WINDOWS_TARGET_XP class condition_variable_t { public: @@ -126,7 +132,54 @@ namespace zmq condition_variable_t (const condition_variable_t&); void operator = (const condition_variable_t&); }; +#else + class condition_variable_t + { + public: + inline condition_variable_t() + { + + } + + inline ~condition_variable_t() + { + + } + + inline int wait(mutex_t* mutex_, int timeout_) + { + std::unique_lock lck(mtx); // lock mtx + mutex_->unlock(); // unlock mutex_ + int res = 0; + if(timeout_ == -1) { + cv.wait(lck); // unlock mtx and wait cv.notify_all(), lock mtx after cv.notify_all() + } else if (cv.wait_for(lck, std::chrono::milliseconds(timeout_)) == std::cv_status::timeout) { + // time expired + errno = EAGAIN; + res = -1; + } + lck.unlock(); // unlock mtx + mutex_->lock(); // lock mutex_ + return res; + } + + inline void broadcast() + { + std::unique_lock lck(mtx); // lock mtx + cv.notify_all(); + } + + private: + + std::condition_variable cv; + std::mutex mtx; + + // Disable copy construction and assignment. + condition_variable_t(const condition_variable_t&); + void operator = (const condition_variable_t&); + }; +#endif } #endif diff --git a/src/tcp_address.cpp b/src/tcp_address.cpp index 4987e3ee..d0aee8c1 100644 --- a/src/tcp_address.cpp +++ b/src/tcp_address.cpp @@ -245,7 +245,9 @@ int zmq::tcp_address_t::get_interface_name(unsigned long index, char ** dest) co char * if_name_result = NULL; +#ifndef ZMQ_HAVE_WINDOWS_TARGET_XP if_name_result = if_indextoname(index, buffer); +#endif if (if_name_result == NULL) { free(buffer);