Cleaning up compatibility stuff of very old boost versions.

This commit is contained in:
lotodore
2011-03-05 12:26:55 +00:00
parent 9b8e250876
commit 5122c26f8a
3 changed files with 2 additions and 42 deletions
+1 -32
View File
@@ -18,20 +18,8 @@
***************************************************************************/
#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.
class ThreadStarter
@@ -92,19 +80,9 @@ Thread::Join(unsigned msecTimeout)
tmpIsTerminated = true;
} else {
// Wait for the termination of the application code.
#if (BOOST_VERSION) >= 103500
boost::defer_lock_t defer;
boost::timed_mutex::scoped_timed_lock lock(m_isTerminatedMutex, defer);
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) {
@@ -122,11 +100,7 @@ Thread::Join(unsigned msecTimeout)
void
Thread::Msleep(unsigned msecs)
{
boost::xtime t;
boost::xtime_get(&t, boost::TIME_UTC);
ADD_MSEC_TO_XTIME(t, msecs);
boost::thread::sleep(t);
boost::this_thread::sleep(boost::posix_time::millisec(msecs));
}
void
@@ -141,14 +115,9 @@ Thread::MainWrapper()
bool
Thread::ShouldTerminate() const
{
#if (BOOST_VERSION) >= 103500
boost::defer_lock_t defer;
boost::timed_mutex::scoped_try_lock lock(m_shouldTerminateMutex, defer);
return lock.try_lock();
#else
boost::timed_mutex::scoped_try_lock lock(m_shouldTerminateMutex);
return lock.locked();
#endif
}
bool
+1 -1
View File
@@ -55,7 +55,7 @@ typedef int pid_t;
// "2. Can I use OpenSSL with GPL software?"
// 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
#endif
-9
View File
@@ -19,7 +19,6 @@
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <boost/version.hpp> // solve compatibility issues
#include <net/socket_startup.h>
#include <core/openssl_wrapper.h>
@@ -46,20 +45,12 @@ extern "C" {
}
int gcry_bmutex_lock(void **obj)
{
#if (BOOST_VERSION) >= 103500
((boost::mutex *)(*obj))->lock();
#else
boost::detail::thread::lock_ops<boost::mutex>::lock(*((boost::mutex *)*obj));
#endif
return 0;
}
int gcry_bmutex_unlock(void **obj)
{
#if (BOOST_VERSION) >= 103500
((boost::mutex *)(*obj))->unlock();
#else
boost::detail::thread::lock_ops<boost::mutex>::unlock(*((boost::mutex *)*obj));
#endif
return 0;
}