summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2012-04-19 20:17:47 +0200
committerMartin Sustrik <sustrik@250bpm.com>2012-04-20 06:59:47 +0200
commitce2b29af43b4624e053377ef00c5a7e2b80c08b7 (patch)
treeaf6bfc20de9fd2c9752dc1924a2db45b040133b6 /src
parent18a61b7cd60399944972482fabab4d7e81ffddae (diff)
Clock instance removed from surveyor_t
SURVEYOR socket now uses clock instance from socket_base_t for measuring survey timeout. This allows for better performance in tight xs_recv() loops. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src')
-rw-r--r--src/socket_base.cpp4
-rw-r--r--src/socket_base.hpp3
-rw-r--r--src/surveyor.cpp4
-rw-r--r--src/surveyor.hpp4
4 files changed, 9 insertions, 6 deletions
diff --git a/src/socket_base.cpp b/src/socket_base.cpp
index 39881d5..3e57c28 100644
--- a/src/socket_base.cpp
+++ b/src/socket_base.cpp
@@ -933,3 +933,7 @@ int xs::socket_base_t::sndtimeo ()
return options.sndtimeo;
}
+uint64_t xs::socket_base_t::now_ms ()
+{
+ return clock.now_ms ();
+}
diff --git a/src/socket_base.hpp b/src/socket_base.hpp
index 0f7dca8..54a5f0a 100644
--- a/src/socket_base.hpp
+++ b/src/socket_base.hpp
@@ -133,6 +133,9 @@ namespace xs
// Delay actual destruction of the socket.
void process_destroy ();
+ // Measure time in efficient manner.
+ uint64_t now_ms ();
+
private:
// Initialise the object. This function is separate from constructor
diff --git a/src/surveyor.cpp b/src/surveyor.cpp
index b76128b..2208146 100644
--- a/src/surveyor.cpp
+++ b/src/surveyor.cpp
@@ -75,7 +75,7 @@ int xs::surveyor_t::xsend (msg_t *msg_, int flags_)
if (!options.survey_timeout)
timeout = -1;
else
- timeout = clock.now_ms () + options.survey_timeout;
+ timeout = now_ms () + options.survey_timeout;
return 0;
}
@@ -132,7 +132,7 @@ bool xs::surveyor_t::xhas_out ()
int xs::surveyor_t::rcvtimeo ()
{
- int t = timeout - clock.now_ms ();
+ int t = timeout - now_ms ();
if (t < 0)
return options.rcvtimeo;
if (options.rcvtimeo < 0)
diff --git a/src/surveyor.hpp b/src/surveyor.hpp
index a77af49..e79dab0 100644
--- a/src/surveyor.hpp
+++ b/src/surveyor.hpp
@@ -23,7 +23,6 @@
#include "xsurveyor.hpp"
#include "stdint.hpp"
-#include "clock.hpp"
namespace xs
{
@@ -58,9 +57,6 @@ namespace xs
// The time instant when the current survey expires.
uint64_t timeout;
- // Provides a way to measure time quickly.
- clock_t clock;
-
surveyor_t (const surveyor_t&);
const surveyor_t &operator = (const surveyor_t&);
};