Skip to content

Commit 2dc7312

Browse files
flixrjihoonl
authored andcommitted
use SteadyTimer (if available) for cleaning up inactive streams (#63)
* use SteadyTimer for cleaning up inactive streams so that cleanup works correctly even if system time changes SteadyTimer is available since roscpp 1.13.1 * possibility to use SteadyTimer on older ROS versions when SteadyTimer has been backported to those...
1 parent 3441527 commit 2dc7312

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

include/web_video_server/web_video_server.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ class WebVideoServer
5151
void cleanup_inactive_streams();
5252

5353
ros::NodeHandle nh_;
54+
#if ROS_VERSION_MINIMUM(1, 13, 1) || defined USE_STEADY_TIMER
55+
ros::SteadyTimer cleanup_timer_;
56+
#else
5457
ros::Timer cleanup_timer_;
58+
#endif
5559
int ros_threads_;
5660
int port_;
5761
std::string address_;

src/web_video_server.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ WebVideoServer::WebVideoServer(ros::NodeHandle &nh, ros::NodeHandle &private_nh)
4444
nh_(nh), handler_group_(
4545
async_web_server_cpp::HttpReply::stock_reply(async_web_server_cpp::HttpReply::not_found))
4646
{
47+
#if ROS_VERSION_MINIMUM(1, 13, 1) || defined USE_STEADY_TIMER
48+
cleanup_timer_ = nh.createSteadyTimer(ros::WallDuration(0.5), boost::bind(&WebVideoServer::cleanup_inactive_streams, this));
49+
#else
4750
cleanup_timer_ = nh.createTimer(ros::Duration(0.5), boost::bind(&WebVideoServer::cleanup_inactive_streams, this));
51+
#endif
4852

4953
private_nh.param("port", port_, 8080);
5054
private_nh.param("verbose", __verbose, true);

0 commit comments

Comments
 (0)