Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
d8b975f4
Commit
d8b975f4
authored
Aug 28, 2010
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msg_store_t renamed to swap_t
parent
d90b4071
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
34 deletions
+34
-34
Makefile.am
src/Makefile.am
+2
-2
pipe.cpp
src/pipe.cpp
+1
-1
pipe.hpp
src/pipe.hpp
+2
-2
swap.cpp
src/swap.cpp
+15
-15
swap.hpp
src/swap.hpp
+14
-14
No files found.
src/Makefile.am
View file @
d8b975f4
...
...
@@ -76,7 +76,6 @@ libzmq_la_SOURCES = \
lb.hpp
\
likely.hpp
\
msg_content.hpp
\
msg_store.hpp
\
mutex.hpp
\
named_session.hpp
\
object.hpp
\
...
...
@@ -105,6 +104,7 @@ libzmq_la_SOURCES = \
stdint.hpp
\
streamer.hpp
\
sub.hpp
\
swap.hpp
\
tcp_connecter.hpp
\
tcp_listener.hpp
\
tcp_socket.hpp
\
...
...
@@ -138,7 +138,6 @@ libzmq_la_SOURCES = \
ip.cpp
\
kqueue.cpp
\
lb.cpp
\
msg_store.cpp
\
named_session.cpp
\
object.cpp
\
options.cpp
\
...
...
@@ -162,6 +161,7 @@ libzmq_la_SOURCES = \
socket_base.cpp
\
streamer.cpp
\
sub.cpp
\
swap.cpp
\
tcp_connecter.cpp
\
tcp_listener.cpp
\
tcp_socket.cpp
\
...
...
src/pipe.cpp
View file @
d8b975f4
...
...
@@ -174,7 +174,7 @@ zmq::writer_t::writer_t (object_t *parent_, pipe_t *pipe_, reader_t *reader_,
// Open the swap file, if required.
if
(
swap_size_
>
0
)
{
swap
=
new
(
std
::
nothrow
)
msg_store
_t
(
swap_size_
);
swap
=
new
(
std
::
nothrow
)
swap
_t
(
swap_size_
);
zmq_assert
(
swap
);
int
rc
=
swap
->
init
();
zmq_assert
(
rc
==
0
);
...
...
src/pipe.hpp
View file @
d8b975f4
...
...
@@ -25,7 +25,7 @@
#include "stdint.hpp"
#include "yarray_item.hpp"
#include "ypipe.hpp"
#include "
msg_store
.hpp"
#include "
swap
.hpp"
#include "config.hpp"
#include "object.hpp"
...
...
@@ -183,7 +183,7 @@ namespace zmq
// Pointer to the message swap. If NULL, messages are always
// kept in main memory.
msg_store
_t
*
swap
;
swap
_t
*
swap
;
// Sink for the events (either the socket or the session).
i_writer_events
*
sink
;
...
...
src/
msg_store
.cpp
→
src/
swap
.cpp
View file @
d8b975f4
...
...
@@ -35,11 +35,11 @@
#include <sstream>
#include <algorithm>
#include "swap.hpp"
#include "atomic_counter.hpp"
#include "msg_store.hpp"
#include "err.hpp"
zmq
::
msg_store_t
::
msg_store
_t
(
int64_t
filesize_
,
size_t
block_size_
)
:
zmq
::
swap_t
::
swap
_t
(
int64_t
filesize_
,
size_t
block_size_
)
:
fd
(
-
1
),
filesize
(
filesize_
),
file_pos
(
0
),
...
...
@@ -60,7 +60,7 @@ zmq::msg_store_t::msg_store_t (int64_t filesize_, size_t block_size_) :
read_buf
=
write_buf
=
buf1
;
}
zmq
::
msg_store_t
::~
msg_store
_t
()
zmq
::
swap_t
::~
swap
_t
()
{
delete
[]
buf1
;
delete
[]
buf2
;
...
...
@@ -83,7 +83,7 @@ zmq::msg_store_t::~msg_store_t ()
errno_assert
(
rc
==
0
);
}
int
zmq
::
msg_store
_t
::
init
()
int
zmq
::
swap
_t
::
init
()
{
static
zmq
::
atomic_counter_t
seqnum
(
0
);
...
...
@@ -116,7 +116,7 @@ int zmq::msg_store_t::init ()
return
0
;
}
bool
zmq
::
msg_store
_t
::
store
(
zmq_msg_t
*
msg_
)
bool
zmq
::
swap
_t
::
store
(
zmq_msg_t
*
msg_
)
{
size_t
msg_size
=
zmq_msg_size
(
msg_
);
...
...
@@ -138,7 +138,7 @@ bool zmq::msg_store_t::store (zmq_msg_t *msg_)
return
true
;
}
void
zmq
::
msg_store
_t
::
fetch
(
zmq_msg_t
*
msg_
)
void
zmq
::
swap
_t
::
fetch
(
zmq_msg_t
*
msg_
)
{
// There must be at least one message available.
zmq_assert
(
read_pos
!=
write_pos
);
...
...
@@ -157,12 +157,12 @@ void zmq::msg_store_t::fetch (zmq_msg_t *msg_)
copy_from_file
(
zmq_msg_data
(
msg_
),
msg_size
);
}
void
zmq
::
msg_store
_t
::
commit
()
void
zmq
::
swap
_t
::
commit
()
{
commit_pos
=
write_pos
;
}
void
zmq
::
msg_store
_t
::
rollback
()
void
zmq
::
swap
_t
::
rollback
()
{
if
(
commit_pos
==
write_pos
||
read_pos
==
write_pos
)
return
;
...
...
@@ -183,17 +183,17 @@ void zmq::msg_store_t::rollback ()
write_pos
=
commit_pos
;
}
bool
zmq
::
msg_store
_t
::
empty
()
bool
zmq
::
swap
_t
::
empty
()
{
return
read_pos
==
write_pos
;
}
bool
zmq
::
msg_store
_t
::
full
()
bool
zmq
::
swap
_t
::
full
()
{
return
buffer_space
()
==
1
;
}
void
zmq
::
msg_store
_t
::
copy_from_file
(
void
*
buffer_
,
size_t
count_
)
void
zmq
::
swap
_t
::
copy_from_file
(
void
*
buffer_
,
size_t
count_
)
{
char
*
dest_ptr
=
(
char
*
)
buffer_
;
size_t
chunk_size
,
remainder
=
count_
;
...
...
@@ -217,7 +217,7 @@ void zmq::msg_store_t::copy_from_file (void *buffer_, size_t count_)
}
}
void
zmq
::
msg_store
_t
::
copy_to_file
(
const
void
*
buffer_
,
size_t
count_
)
void
zmq
::
swap
_t
::
copy_to_file
(
const
void
*
buffer_
,
size_t
count_
)
{
char
*
source_ptr
=
(
char
*
)
buffer_
;
size_t
chunk_size
,
remainder
=
count_
;
...
...
@@ -246,7 +246,7 @@ void zmq::msg_store_t::copy_to_file (const void *buffer_, size_t count_)
}
}
void
zmq
::
msg_store
_t
::
fill_buf
(
char
*
buf
,
int64_t
pos
)
void
zmq
::
swap
_t
::
fill_buf
(
char
*
buf
,
int64_t
pos
)
{
if
(
file_pos
!=
pos
)
{
#ifdef ZMQ_HAVE_WINDOWS
...
...
@@ -272,7 +272,7 @@ void zmq::msg_store_t::fill_buf (char *buf, int64_t pos)
file_pos
+=
octets_total
;
}
void
zmq
::
msg_store
_t
::
save_write_buf
()
void
zmq
::
swap
_t
::
save_write_buf
()
{
if
(
file_pos
!=
write_buf_start_addr
)
{
#ifdef ZMQ_HAVE_WINDOWS
...
...
@@ -298,7 +298,7 @@ void zmq::msg_store_t::save_write_buf ()
file_pos
+=
octets_total
;
}
int64_t
zmq
::
msg_store
_t
::
buffer_space
()
int64_t
zmq
::
swap
_t
::
buffer_space
()
{
if
(
write_pos
<
read_pos
)
return
read_pos
-
write_pos
;
...
...
src/
msg_store
.hpp
→
src/
swap
.hpp
View file @
d8b975f4
...
...
@@ -17,8 +17,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ZMQ_
MSG_STORE
_HPP_INCLUDED__
#define __ZMQ_
MSG_STORE
_HPP_INCLUDED__
#ifndef __ZMQ_
SWAP
_HPP_INCLUDED__
#define __ZMQ_
SWAP
_HPP_INCLUDED__
#include "../include/zmq.h"
...
...
@@ -28,38 +28,38 @@
namespace
zmq
{
// This class implements a message s
tore
. Messages are retrieved from
// the s
tore
in the same order as they entered it.
// This class implements a message s
wap
. Messages are retrieved from
// the s
wap
in the same order as they entered it.
class
msg_store
_t
class
swap
_t
{
public
:
enum
{
default_block_size
=
8192
};
// Creates
message store
.
msg_store
_t
(
int64_t
filesize_
,
size_t
block_size_
=
default_block_size
);
// Creates
the swap
.
swap
_t
(
int64_t
filesize_
,
size_t
block_size_
=
default_block_size
);
~
msg_store
_t
();
~
swap
_t
();
int
init
();
// Stores the message into the
message store
. The function
// returns false if the
message store
is full; true otherwise.
// Stores the message into the
swap
. The function
// returns false if the
swap
is full; true otherwise.
bool
store
(
zmq_msg_t
*
msg_
);
// Fetches the oldest message from the
message store
. It is an error
// to call this function when the
message store
is empty.
// Fetches the oldest message from the
swap
. It is an error
// to call this function when the
swap
is empty.
void
fetch
(
zmq_msg_t
*
msg_
);
void
commit
();
void
rollback
();
// Returns true if the
message store
is empty; false otherwise.
// Returns true if the
swap
is empty; false otherwise.
bool
empty
();
// Returns true if and only if the s
tore
is full.
// Returns true if and only if the s
wap
is full.
bool
full
();
private
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment