diff options
author | Martin Sustrik <sustrik@fastmq.commkdir> | 2009-12-10 08:25:21 +0100 |
---|---|---|
committer | Martin Sustrik <sustrik@fastmq.commkdir> | 2009-12-10 08:25:21 +0100 |
commit | 72dacc35702a14ab0bb5a2650dffbb3bbda63175 (patch) | |
tree | 9cc06e849d344ecc4b6b9778a1f059ad69ac4309 | |
parent | 1c1dfb50f88002ce7a024f2d8980b968d3aee1ae (diff) |
zero-copy on tx side optimised to minimise number of user/kernel space transitions
-rw-r--r-- | src/encoder.hpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/encoder.hpp b/src/encoder.hpp index 6387c4e..c41180f 100644 --- a/src/encoder.hpp +++ b/src/encoder.hpp @@ -56,12 +56,18 @@ namespace zmq // If we are able to fill whole buffer in a single go, let's // use zero-copy. There's no disadvantage to it as we cannot - // stuck multiple messages into the buffer anyway. + // stuck multiple messages into the buffer anyway. Note that + // subsequent write(s) are non-blocking, thus each single + // write writes at most SO_SNDBUF bytes at once not depending + // on how large is the chunk returned from here. + // As a consequence, large messages being sent won't block + // other engines running in the same I/O thread for excessive + // amounts of time. if (pos == 0 && to_write >= *size_) { *data_ = write_pos; - write_pos += *size_; - to_write -= *size_; - pos = *size_; + write_pos += to_write; + pos = to_write; + to_write = 0; break; } |