Cleaning up compatibility stuff of very old boost versions.
This commit is contained in:
@@ -18,20 +18,8 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include <boost/version.hpp> // solve compatibility issues
|
|
||||||
|
|
||||||
|
|
||||||
// This is ugly, but I can't help it.
|
|
||||||
inline void ADD_MSEC_TO_XTIME(boost::xtime &xt, unsigned msec)
|
|
||||||
{
|
|
||||||
xt.sec += msec / 1000;
|
|
||||||
xt.nsec += (msec % 1000) * 1000000;
|
|
||||||
if (xt.nsec > NANOSECONDS_PER_SECOND) {
|
|
||||||
xt.sec++;
|
|
||||||
xt.nsec -= NANOSECONDS_PER_SECOND;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Helper class for thread creation.
|
// Helper class for thread creation.
|
||||||
class ThreadStarter
|
class ThreadStarter
|
||||||
@@ -92,19 +80,9 @@ Thread::Join(unsigned msecTimeout)
|
|||||||
tmpIsTerminated = true;
|
tmpIsTerminated = true;
|
||||||
} else {
|
} else {
|
||||||
// Wait for the termination of the application code.
|
// Wait for the termination of the application code.
|
||||||
#if (BOOST_VERSION) >= 103500
|
|
||||||
boost::defer_lock_t defer;
|
boost::defer_lock_t defer;
|
||||||
boost::timed_mutex::scoped_timed_lock lock(m_isTerminatedMutex, defer);
|
boost::timed_mutex::scoped_timed_lock lock(m_isTerminatedMutex, defer);
|
||||||
tmpIsTerminated = lock.timed_lock(boost::posix_time::millisec(msecTimeout));
|
tmpIsTerminated = lock.timed_lock(boost::posix_time::millisec(msecTimeout));
|
||||||
#else
|
|
||||||
// Calculate time after timeout
|
|
||||||
boost::xtime t;
|
|
||||||
boost::xtime_get(&t, boost::TIME_UTC);
|
|
||||||
ADD_MSEC_TO_XTIME(t, msecTimeout);
|
|
||||||
|
|
||||||
boost::timed_mutex::scoped_timed_lock lock(m_isTerminatedMutex, t);
|
|
||||||
tmpIsTerminated = lock.locked();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmpIsTerminated) {
|
if (tmpIsTerminated) {
|
||||||
@@ -122,11 +100,7 @@ Thread::Join(unsigned msecTimeout)
|
|||||||
void
|
void
|
||||||
Thread::Msleep(unsigned msecs)
|
Thread::Msleep(unsigned msecs)
|
||||||
{
|
{
|
||||||
boost::xtime t;
|
boost::this_thread::sleep(boost::posix_time::millisec(msecs));
|
||||||
boost::xtime_get(&t, boost::TIME_UTC);
|
|
||||||
ADD_MSEC_TO_XTIME(t, msecs);
|
|
||||||
|
|
||||||
boost::thread::sleep(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -141,14 +115,9 @@ Thread::MainWrapper()
|
|||||||
bool
|
bool
|
||||||
Thread::ShouldTerminate() const
|
Thread::ShouldTerminate() const
|
||||||
{
|
{
|
||||||
#if (BOOST_VERSION) >= 103500
|
|
||||||
boost::defer_lock_t defer;
|
boost::defer_lock_t defer;
|
||||||
boost::timed_mutex::scoped_try_lock lock(m_shouldTerminateMutex, defer);
|
boost::timed_mutex::scoped_try_lock lock(m_shouldTerminateMutex, defer);
|
||||||
return lock.try_lock();
|
return lock.try_lock();
|
||||||
#else
|
|
||||||
boost::timed_mutex::scoped_try_lock lock(m_shouldTerminateMutex);
|
|
||||||
return lock.locked();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ typedef int pid_t;
|
|||||||
// "2. Can I use OpenSSL with GPL software?"
|
// "2. Can I use OpenSSL with GPL software?"
|
||||||
// http://www.openssl.org/support/faq.html#LEGAL2
|
// http://www.openssl.org/support/faq.html#LEGAL2
|
||||||
//
|
//
|
||||||
#if defined(_WIN64) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
|
#if defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
|
||||||
#define HAVE_OPENSSL
|
#define HAVE_OPENSSL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <boost/version.hpp> // solve compatibility issues
|
|
||||||
|
|
||||||
#include <net/socket_startup.h>
|
#include <net/socket_startup.h>
|
||||||
#include <core/openssl_wrapper.h>
|
#include <core/openssl_wrapper.h>
|
||||||
@@ -46,20 +45,12 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
int gcry_bmutex_lock(void **obj)
|
int gcry_bmutex_lock(void **obj)
|
||||||
{
|
{
|
||||||
#if (BOOST_VERSION) >= 103500
|
|
||||||
((boost::mutex *)(*obj))->lock();
|
((boost::mutex *)(*obj))->lock();
|
||||||
#else
|
|
||||||
boost::detail::thread::lock_ops<boost::mutex>::lock(*((boost::mutex *)*obj));
|
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int gcry_bmutex_unlock(void **obj)
|
int gcry_bmutex_unlock(void **obj)
|
||||||
{
|
{
|
||||||
#if (BOOST_VERSION) >= 103500
|
|
||||||
((boost::mutex *)(*obj))->unlock();
|
((boost::mutex *)(*obj))->unlock();
|
||||||
#else
|
|
||||||
boost::detail::thread::lock_ops<boost::mutex>::unlock(*((boost::mutex *)*obj));
|
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user