Consider replacing deadline_timer with steady_timer or system_timer

2,114 views
Skip to first unread message

Max Dmitrichenko

unread,
Nov 2, 2014, 4:24:08 PM11/2/14
to webso...@googlegroups.com
Hi, Peter!

I'm trying to build my project on RHEL 7.0 which has GCC 4.8.2 as system compiler. Sadly, but I have to disable Boost.Asio from using Boost.DateTime (with #define BOOST_ASIO_DISABLE_BOOST_DATE_TIME), because otherwise another library is not compiled with the new GCC. After this I've got a lot of errors with WebSocket++, because it uses boost::asio::deadline_timer in its code.

boost::asio::deadline_timer is a timer on top of Boost.DateTime library which is pretty much obsoleted by Boost.Chrono (or std::chrono) when dealing with times. I see that you've made some preparations for this (websocketpp/common/chrono.hpp).

Also note, that another problem on GCC 4.8 is in this code (websocketpp/logger/basic.hpp):

#ifdef _WEBSOCKETPP_CPP11_CHRONO_
return os << std::put_time(lt,"%Y-%m-%d %H:%M:%S");
#else // Falls back to strftime, which requires a temporary copy of the string.

AFAIK, std::put_time is implemented only in recent versions of GCC 4.9, and it's not about Chrono library, but IoManip.

--
With best regards,
  Max

Max Dmitrichenko

unread,
Nov 2, 2014, 6:22:12 PM11/2/14
to webso...@googlegroups.com
Hi, again!

On Monday, November 3, 2014 12:24:08 AM UTC+3, Max Dmitrichenko wrote:
Also note, that another problem on GCC 4.8 is in this code (websocketpp/logger/basic.hpp):

#ifdef _WEBSOCKETPP_CPP11_CHRONO_
return os << std::put_time(lt,"%Y-%m-%d %H:%M:%S");
#else // Falls back to strftime, which requires a temporary copy of the string.

AFAIK, std::put_time is implemented only in recent versions of GCC 4.9, and it's not about Chrono library, but IoManip.
 
I've looked through the code and noticed, that I could deal with it using BOOST_ASIO_DISABLE_STD_CHRONO. Actually, it was already defined in my project and I've included <websocketpp/config/boost_config.hpp> as the very first include of WebSocket++ but _WEBSOCKETPP_CPP11_CHRONO_ was still defined anyway.

Apparently, there is a bug or typo in the <websocketpp/config/boost_config.hpp>. Patch is attached.

websocketpp_boost_config.patch

Peter Thorson

unread,
Nov 3, 2014, 10:14:08 AM11/3/14
to Max Dmitrichenko, webso...@googlegroups.com
Hi Max,

I’ve applied the boost_config patch below and fixed the use of std::put_time to only be used with a put time specific token rather than the chrono header, which I agree put_time is unrelated to.

With respect to deadline_timer, ultimately, the plan is to switch to using timers based on the chrono libraries. However, support for boost::chrono doesn’t go back far enough for me to get rid of it entirely today. The default packaged versions of boost for RHEL 6 and Ubuntu 12.04 LTS are too old to have it. I may look into doing a hybrid approach like I’ve done for some of the other areas (switch between deadline timer and steady timer based on build settings). Setting up these cases and adequately testing them is time consuming though.

Best,

Peter

--
You received this message because you are subscribed to the Google Groups "WebSocket++" group.
To unsubscribe from this group and stop receiving emails from it, send an email to websocketpp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<websocketpp_boost_config.patch>

Reply all
Reply to author
Forward
0 new messages