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
f8bf3a4c
Commit
f8bf3a4c
authored
Jun 27, 2011
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename i_inout to i_engine_sink
Signed-off-by:
Martin Sustrik
<
sustrik@250bpm.com
>
parent
3ae73ee1
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
81 additions
and
111 deletions
+81
-111
Makefile.am
src/Makefile.am
+0
-1
decoder.cpp
src/decoder.cpp
+5
-5
decoder.hpp
src/decoder.hpp
+2
-2
encoder.cpp
src/encoder.cpp
+5
-5
encoder.hpp
src/encoder.hpp
+2
-2
i_engine.hpp
src/i_engine.hpp
+22
-1
i_inout.hpp
src/i_inout.hpp
+0
-49
pgm_receiver.cpp
src/pgm_receiver.cpp
+6
-7
pgm_receiver.hpp
src/pgm_receiver.hpp
+3
-3
pgm_sender.cpp
src/pgm_sender.cpp
+3
-3
pgm_sender.hpp
src/pgm_sender.hpp
+1
-1
session.hpp
src/session.hpp
+3
-3
zmq_engine.cpp
src/zmq_engine.cpp
+21
-22
zmq_engine.hpp
src/zmq_engine.hpp
+4
-4
zmq_init.hpp
src/zmq_init.hpp
+4
-3
No files found.
src/Makefile.am
View file @
f8bf3a4c
...
...
@@ -24,7 +24,6 @@ libzmq_la_SOURCES = \
err.hpp
\
fd.hpp
\
fq.hpp
\
i_inout.hpp
\
io_object.hpp
\
io_thread.hpp
\
ip.hpp
\
...
...
src/decoder.cpp
View file @
f8bf3a4c
...
...
@@ -22,13 +22,13 @@
#include <string.h>
#include "decoder.hpp"
#include "i_
inout
.hpp"
#include "i_
engine
.hpp"
#include "wire.hpp"
#include "err.hpp"
zmq
::
decoder_t
::
decoder_t
(
size_t
bufsize_
,
int64_t
maxmsgsize_
)
:
decoder_base_t
<
decoder_t
>
(
bufsize_
),
destination
(
NULL
),
sink
(
NULL
),
maxmsgsize
(
maxmsgsize_
)
{
int
rc
=
in_progress
.
init
();
...
...
@@ -44,9 +44,9 @@ zmq::decoder_t::~decoder_t ()
errno_assert
(
rc
==
0
);
}
void
zmq
::
decoder_t
::
set_
inout
(
i_inout
*
destination
_
)
void
zmq
::
decoder_t
::
set_
sink
(
i_engine_sink
*
sink
_
)
{
destination
=
destination
_
;
sink
=
sink
_
;
}
bool
zmq
::
decoder_t
::
one_byte_size_ready
()
...
...
@@ -136,7 +136,7 @@ bool zmq::decoder_t::message_ready ()
{
// Message is completely read. Push it further and start reading
// new message. (in_progress is a 0-byte message after this point.)
if
(
!
destination
||
!
destination
->
write
(
&
in_progress
))
if
(
!
sink
||
!
sink
->
write
(
&
in_progress
))
return
false
;
next_step
(
tmpbuf
,
1
,
&
decoder_t
::
one_byte_size_ready
);
...
...
src/decoder.hpp
View file @
f8bf3a4c
...
...
@@ -184,7 +184,7 @@ namespace zmq
decoder_t
(
size_t
bufsize_
,
int64_t
maxmsgsize_
);
~
decoder_t
();
void
set_
inout
(
struct
i_inout
*
destination
_
);
void
set_
sink
(
struct
i_engine_sink
*
sink
_
);
private
:
...
...
@@ -193,7 +193,7 @@ namespace zmq
bool
flags_ready
();
bool
message_ready
();
struct
i_
inout
*
destination
;
struct
i_
engine_sink
*
sink
;
unsigned
char
tmpbuf
[
8
];
msg_t
in_progress
;
...
...
src/encoder.cpp
View file @
f8bf3a4c
...
...
@@ -19,12 +19,12 @@
*/
#include "encoder.hpp"
#include "i_
inout
.hpp"
#include "i_
engine
.hpp"
#include "wire.hpp"
zmq
::
encoder_t
::
encoder_t
(
size_t
bufsize_
)
:
encoder_base_t
<
encoder_t
>
(
bufsize_
),
s
ource
(
NULL
)
s
ink
(
NULL
)
{
int
rc
=
in_progress
.
init
();
errno_assert
(
rc
==
0
);
...
...
@@ -39,9 +39,9 @@ zmq::encoder_t::~encoder_t ()
errno_assert
(
rc
==
0
);
}
void
zmq
::
encoder_t
::
set_
inout
(
i_inout
*
source
_
)
void
zmq
::
encoder_t
::
set_
sink
(
i_engine_sink
*
sink
_
)
{
s
ource
=
source
_
;
s
ink
=
sink
_
;
}
bool
zmq
::
encoder_t
::
size_ready
()
...
...
@@ -62,7 +62,7 @@ bool zmq::encoder_t::message_ready ()
// Note that new state is set only if write is successful. That way
// unsuccessful write will cause retry on the next state machine
// invocation.
if
(
!
s
ource
||
!
source
->
read
(
&
in_progress
))
{
if
(
!
s
ink
||
!
sink
->
read
(
&
in_progress
))
{
rc
=
in_progress
.
init
();
errno_assert
(
rc
==
0
);
return
false
;
...
...
src/encoder.hpp
View file @
f8bf3a4c
...
...
@@ -163,14 +163,14 @@ namespace zmq
encoder_t
(
size_t
bufsize_
);
~
encoder_t
();
void
set_
inout
(
struct
i_inout
*
source
_
);
void
set_
sink
(
struct
i_engine_sink
*
sink
_
);
private
:
bool
size_ready
();
bool
message_ready
();
struct
i_
inout
*
source
;
struct
i_
engine_sink
*
sink
;
msg_t
in_progress
;
unsigned
char
tmpbuf
[
10
];
...
...
src/i_engine.hpp
View file @
f8bf3a4c
...
...
@@ -24,13 +24,15 @@
namespace
zmq
{
// Abstract interface to be implemented by various engines.
struct
i_engine
{
virtual
~
i_engine
()
{}
// Plug the engine to the session.
virtual
void
plug
(
class
io_thread_t
*
io_thread_
,
struct
i_
inout
*
inout
_
)
=
0
;
struct
i_
engine_sink
*
sink
_
)
=
0
;
// Unplug the engine from the session.
virtual
void
unplug
()
=
0
;
...
...
@@ -48,6 +50,25 @@ namespace zmq
virtual
void
activate_out
()
=
0
;
};
// Abstract interface to be implemented by engine sinks such as sessions.
struct
i_engine_sink
{
virtual
~
i_engine_sink
()
{}
// Engine asks for a message to send to the network.
virtual
bool
read
(
class
msg_t
*
msg_
)
=
0
;
// Engine received message from the network and sends it further on.
virtual
bool
write
(
class
msg_t
*
msg_
)
=
0
;
// Flush all the previously written messages.
virtual
void
flush
()
=
0
;
// Engine is dead. Drop all the references to it.
virtual
void
detach
()
=
0
;
};
}
#endif
src/i_inout.hpp
deleted
100644 → 0
View file @
3ae73ee1
/*
Copyright (c) 2007-2011 iMatix Corporation
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ZMQ_I_INOUT_HPP_INCLUDED__
#define __ZMQ_I_INOUT_HPP_INCLUDED__
#include "msg.hpp"
#include "stdint.hpp"
namespace
zmq
{
struct
i_inout
{
virtual
~
i_inout
()
{}
// Engine asks for a message to send to the network.
virtual
bool
read
(
msg_t
*
msg_
)
=
0
;
// Engine received message from the network and sends it further on.
virtual
bool
write
(
msg_t
*
msg_
)
=
0
;
// Flush all the previously written messages.
virtual
void
flush
()
=
0
;
// Engine is dead. Drop all the references to it.
virtual
void
detach
()
=
0
;
};
}
#endif
src/pgm_receiver.cpp
View file @
f8bf3a4c
...
...
@@ -32,7 +32,6 @@
#include "err.hpp"
#include "stdint.hpp"
#include "wire.hpp"
#include "i_inout.hpp"
zmq
::
pgm_receiver_t
::
pgm_receiver_t
(
class
io_thread_t
*
parent_
,
const
options_t
&
options_
)
:
...
...
@@ -40,7 +39,7 @@ zmq::pgm_receiver_t::pgm_receiver_t (class io_thread_t *parent_,
has_rx_timer
(
false
),
pgm_socket
(
true
,
options_
),
options
(
options_
),
inout
(
NULL
),
sink
(
NULL
),
mru_decoder
(
NULL
),
pending_bytes
(
0
)
{
...
...
@@ -57,7 +56,7 @@ int zmq::pgm_receiver_t::init (bool udp_encapsulation_, const char *network_)
return
pgm_socket
.
init
(
udp_encapsulation_
,
network_
);
}
void
zmq
::
pgm_receiver_t
::
plug
(
io_thread_t
*
io_thread_
,
i_
inout
*
inout
_
)
void
zmq
::
pgm_receiver_t
::
plug
(
io_thread_t
*
io_thread_
,
i_
engine_sink
*
sink
_
)
{
// Retrieve PGM fds and start polling.
int
socket_fd
;
...
...
@@ -68,7 +67,7 @@ void zmq::pgm_receiver_t::plug (io_thread_t *io_thread_, i_inout *inout_)
set_pollin
(
pipe_handle
);
set_pollin
(
socket_handle
);
inout
=
inout
_
;
sink
=
sink
_
;
}
void
zmq
::
pgm_receiver_t
::
unplug
()
...
...
@@ -91,7 +90,7 @@ void zmq::pgm_receiver_t::unplug ()
rm_fd
(
socket_handle
);
rm_fd
(
pipe_handle
);
inout
=
NULL
;
sink
=
NULL
;
}
void
zmq
::
pgm_receiver_t
::
terminate
()
...
...
@@ -218,7 +217,7 @@ void zmq::pgm_receiver_t::in_event ()
it
->
second
.
decoder
=
new
(
std
::
nothrow
)
decoder_t
(
0
,
options
.
maxmsgsize
);
alloc_assert
(
it
->
second
.
decoder
);
it
->
second
.
decoder
->
set_
inout
(
inout
);
it
->
second
.
decoder
->
set_
sink
(
sink
);
}
mru_decoder
=
it
->
second
.
decoder
;
...
...
@@ -244,7 +243,7 @@ void zmq::pgm_receiver_t::in_event ()
}
// Flush any messages decoder may have produced.
inout
->
flush
();
sink
->
flush
();
}
void
zmq
::
pgm_receiver_t
::
timer_event
(
int
token
)
...
...
src/pgm_receiver.hpp
View file @
f8bf3a4c
...
...
@@ -52,7 +52,7 @@ namespace zmq
int
init
(
bool
udp_encapsulation_
,
const
char
*
network_
);
// i_engine interface implementation.
void
plug
(
class
io_thread_t
*
io_thread_
,
struct
i_
inout
*
inout
_
);
void
plug
(
class
io_thread_t
*
io_thread_
,
struct
i_
engine_sink
*
sink
_
);
void
unplug
();
void
terminate
();
void
activate_in
();
...
...
@@ -100,8 +100,8 @@ namespace zmq
// Socket options.
options_t
options
;
//
Parent
session.
i_
inout
*
inout
;
//
Associated
session.
i_
engine_sink
*
sink
;
// Most recently used decoder.
decoder_t
*
mru_decoder
;
...
...
src/pgm_sender.cpp
View file @
f8bf3a4c
...
...
@@ -61,7 +61,7 @@ int zmq::pgm_sender_t::init (bool udp_encapsulation_, const char *network_)
return
rc
;
}
void
zmq
::
pgm_sender_t
::
plug
(
io_thread_t
*
io_thread_
,
i_
inout
*
inout
_
)
void
zmq
::
pgm_sender_t
::
plug
(
io_thread_t
*
io_thread_
,
i_
engine_sink
*
sink
_
)
{
// Alocate 2 fds for PGM socket.
int
downlink_socket_fd
=
0
;
...
...
@@ -69,7 +69,7 @@ void zmq::pgm_sender_t::plug (io_thread_t *io_thread_, i_inout *inout_)
int
rdata_notify_fd
=
0
;
int
pending_notify_fd
=
0
;
encoder
.
set_
inout
(
inout
_
);
encoder
.
set_
sink
(
sink
_
);
// Fill fds from PGM transport and add them to the poller.
pgm_socket
.
get_sender_fds
(
&
downlink_socket_fd
,
&
uplink_socket_fd
,
...
...
@@ -106,7 +106,7 @@ void zmq::pgm_sender_t::unplug ()
rm_fd
(
uplink_handle
);
rm_fd
(
rdata_notify_handle
);
rm_fd
(
pending_notify_handle
);
encoder
.
set_
inout
(
NULL
);
encoder
.
set_
sink
(
NULL
);
}
void
zmq
::
pgm_sender_t
::
terminate
()
...
...
src/pgm_sender.hpp
View file @
f8bf3a4c
...
...
@@ -50,7 +50,7 @@ namespace zmq
int
init
(
bool
udp_encapsulation_
,
const
char
*
network_
);
// i_engine interface implementation.
void
plug
(
class
io_thread_t
*
io_thread_
,
struct
i_
inout
*
inout
_
);
void
plug
(
class
io_thread_t
*
io_thread_
,
struct
i_
engine_sink
*
sink
_
);
void
unplug
();
void
terminate
();
void
activate_in
();
...
...
src/session.hpp
View file @
f8bf3a4c
...
...
@@ -22,7 +22,7 @@
#define __ZMQ_SESSION_HPP_INCLUDED__
#include "own.hpp"
#include "i_
inout
.hpp"
#include "i_
engine
.hpp"
#include "io_object.hpp"
#include "blob.hpp"
#include "pipe.hpp"
...
...
@@ -33,7 +33,7 @@ namespace zmq
class
session_t
:
public
own_t
,
public
io_object_t
,
public
i_
inout
,
public
i_
engine_sink
,
public
i_pipe_events
{
public
:
...
...
@@ -44,7 +44,7 @@ namespace zmq
// To be used once only, when creating the session.
void
attach_pipe
(
class
pipe_t
*
pipe_
);
// i_
inout
interface implementation.
// i_
engine_sink
interface implementation.
bool
read
(
msg_t
*
msg_
);
bool
write
(
msg_t
*
msg_
);
void
flush
();
...
...
src/zmq_engine.cpp
View file @
f8bf3a4c
...
...
@@ -29,7 +29,6 @@
#include "zmq_engine.hpp"
#include "zmq_connecter.hpp"
#include "io_thread.hpp"
#include "i_inout.hpp"
#include "config.hpp"
#include "err.hpp"
...
...
@@ -40,8 +39,8 @@ zmq::zmq_engine_t::zmq_engine_t (fd_t fd_, const options_t &options_) :
outpos
(
NULL
),
outsize
(
0
),
encoder
(
out_batch_size
),
inout
(
NULL
),
ephemeral_
inout
(
NULL
),
sink
(
NULL
),
ephemeral_
sink
(
NULL
),
options
(
options_
),
plugged
(
false
)
{
...
...
@@ -55,18 +54,18 @@ zmq::zmq_engine_t::~zmq_engine_t ()
zmq_assert
(
!
plugged
);
}
void
zmq
::
zmq_engine_t
::
plug
(
io_thread_t
*
io_thread_
,
i_
inout
*
inout
_
)
void
zmq
::
zmq_engine_t
::
plug
(
io_thread_t
*
io_thread_
,
i_
engine_sink
*
sink
_
)
{
zmq_assert
(
!
plugged
);
plugged
=
true
;
ephemeral_
inout
=
NULL
;
ephemeral_
sink
=
NULL
;
// Connect to session/init object.
zmq_assert
(
!
inout
);
zmq_assert
(
inout
_
);
encoder
.
set_
inout
(
inout
_
);
decoder
.
set_
inout
(
inout
_
);
inout
=
inout
_
;
zmq_assert
(
!
sink
);
zmq_assert
(
sink
_
);
encoder
.
set_
sink
(
sink
_
);
decoder
.
set_
sink
(
sink
_
);
sink
=
sink
_
;
// Connect to I/O threads poller object.
io_object_t
::
plug
(
io_thread_
);
...
...
@@ -90,10 +89,10 @@ void zmq::zmq_engine_t::unplug ()
io_object_t
::
unplug
();
// Disconnect from init/session object.
encoder
.
set_
inout
(
NULL
);
decoder
.
set_
inout
(
NULL
);
ephemeral_
inout
=
inout
;
inout
=
NULL
;
encoder
.
set_
sink
(
NULL
);
decoder
.
set_
sink
(
NULL
);
ephemeral_
sink
=
sink
;
sink
=
NULL
;
}
void
zmq
::
zmq_engine_t
::
terminate
()
...
...
@@ -149,13 +148,13 @@ void zmq::zmq_engine_t::in_event ()
// Flush all messages the decoder may have produced.
// If IO handler has unplugged engine, flush transient IO handler.
if
(
unlikely
(
!
plugged
))
{
zmq_assert
(
ephemeral_
inout
);
ephemeral_
inout
->
flush
();
zmq_assert
(
ephemeral_
sink
);
ephemeral_
sink
->
flush
();
}
else
{
inout
->
flush
();
sink
->
flush
();
}
if
(
inout
&&
disconnection
)
if
(
sink
&&
disconnection
)
error
();
}
...
...
@@ -169,8 +168,8 @@ void zmq::zmq_engine_t::out_event ()
// If IO handler has unplugged engine, flush transient IO handler.
if
(
unlikely
(
!
plugged
))
{
zmq_assert
(
ephemeral_
inout
);
ephemeral_
inout
->
flush
();
zmq_assert
(
ephemeral_
sink
);
ephemeral_
sink
->
flush
();
return
;
}
...
...
@@ -219,8 +218,8 @@ void zmq::zmq_engine_t::activate_in ()
void
zmq
::
zmq_engine_t
::
error
()
{
zmq_assert
(
inout
);
inout
->
detach
();
zmq_assert
(
sink
);
sink
->
detach
();
unplug
();
delete
this
;
}
src/zmq_engine.hpp
View file @
f8bf3a4c
...
...
@@ -43,7 +43,7 @@ namespace zmq
~
zmq_engine_t
();
// i_engine interface implementation.
void
plug
(
class
io_thread_t
*
io_thread_
,
struct
i_
inout
*
inout
_
);
void
plug
(
class
io_thread_t
*
io_thread_
,
struct
i_
engine_sink
*
sink
_
);
void
unplug
();
void
terminate
();
void
activate_in
();
...
...
@@ -69,10 +69,10 @@ namespace zmq
size_t
outsize
;
encoder_t
encoder
;
i_
inout
*
inout
;
i_
engine_sink
*
sink
;
// Detached transient
inout handler
.
i_
inout
*
ephemeral_inout
;
// Detached transient
sink
.
i_
engine_sink
*
ephemeral_sink
;
options_t
options
;
...
...
src/zmq_init.hpp
View file @
f8bf3a4c
...
...
@@ -23,7 +23,6 @@
#include <vector>
#include "i_inout.hpp"
#include "i_engine.hpp"
#include "stdint.hpp"
#include "blob.hpp"
...
...
@@ -36,7 +35,9 @@ namespace zmq
// The class handles initialisation phase of 0MQ wire-level protocol.
class
zmq_init_t
:
public
own_t
,
public
i_inout
class
zmq_init_t
:
public
own_t
,
public
i_engine_sink
{
public
:
...
...
@@ -56,7 +57,7 @@ namespace zmq
void
finalise_initialisation
();
void
dispatch_engine
();
// i_
inout
interface implementation.
// i_
engine_sink
interface implementation.
bool
read
(
class
msg_t
*
msg_
);
bool
write
(
class
msg_t
*
msg_
);
void
flush
();
...
...
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