summaryrefslogtreecommitdiff
path: root/src/socket_base.hpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2012-04-17 10:48:59 +0200
committerMartin Sustrik <sustrik@250bpm.com>2012-04-18 07:16:00 +0200
commit464e0d5ed87f5e0c7fa10d13075e62307eba075f (patch)
tree8105f2b380dacc9d7d6407f4b04851a1598d8976 /src/socket_base.hpp
parent3dc909eabddd68ff1b332af1e42978b55a3c17b6 (diff)
Improve efficiency of time measurement in tight loops
This patch instantiate a clock_t instance for each XS socket. Thus, it is shared between subsequent calls to xs_recv (and xs_send). That in turn significantly limits the number of invocations of getimeofday (or similar) when timeouts are used and recv/send is called in a tight loop. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/socket_base.hpp')
-rw-r--r--src/socket_base.hpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/socket_base.hpp b/src/socket_base.hpp
index 9225ce7..0f7dca8 100644
--- a/src/socket_base.hpp
+++ b/src/socket_base.hpp
@@ -32,6 +32,7 @@
#include "atomic_counter.hpp"
#include "mailbox.hpp"
#include "stdint.hpp"
+#include "clock.hpp"
#include "pipe.hpp"
namespace xs
@@ -202,6 +203,9 @@ namespace xs
// True if the last message received had MORE flag set.
bool rcvmore;
+ // Improves efficiency of time measurement.
+ clock_t clock;
+
socket_base_t (const socket_base_t&);
const socket_base_t &operator = (const socket_base_t&);
};