Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
senf
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wiback
senf
Commits
4ab18774
Commit
4ab18774
authored
16 years ago
by
g0dil
Browse files
Options
Downloads
Patches
Plain Diff
PPI: Allow changing the associated handle of an Active/PassiveSocketSInk
parent
de87ee0d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
PPI/IOEvent.hh
+1
-1
1 addition, 1 deletion
PPI/IOEvent.hh
PPI/SocketSink.ct
+43
-0
43 additions, 0 deletions
PPI/SocketSink.ct
PPI/SocketSink.cti
+25
-1
25 additions, 1 deletion
PPI/SocketSink.cti
PPI/SocketSink.hh
+40
-16
40 additions, 16 deletions
PPI/SocketSink.hh
with
109 additions
and
18 deletions
PPI/IOEvent.hh
+
1
−
1
View file @
4ab18774
...
@@ -123,7 +123,7 @@ namespace ppi {
...
@@ -123,7 +123,7 @@ namespace ppi {
}}
}}
///////////////////////////////hh.e////////////////////////////////////////
///////////////////////////////hh.e////////////////////////////////////////
//
#include "IOEvent.cci"
#include
"IOEvent.cci"
//#include "IOEvent.ct"
//#include "IOEvent.ct"
#include
"IOEvent.cti"
#include
"IOEvent.cti"
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
PPI/SocketSink.ct
+
43
−
0
View file @
4ab18774
...
@@ -33,6 +33,21 @@
...
@@ -33,6 +33,21 @@
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// senf::ppi::module::ActiveSocketSink<Writer>
// senf::ppi::module::ActiveSocketSink<Writer>
template <class Writer>
prefix_ senf::ppi::module::ActiveSocketSink<Writer>::ActiveSocketSink()
{
registerEvent( event_, &ActiveSocketSink::write );
route(input, event_);
}
template <class Writer>
prefix_ senf::ppi::module::ActiveSocketSink<Writer>::ActiveSocketSink(Writer const & writer)
: writer_ (writer)
{
registerEvent( event_, &ActiveSocketSink::write );
route(input, event_);
}
template <class Writer>
template <class Writer>
prefix_ senf::ppi::module::ActiveSocketSink<Writer>::ActiveSocketSink(Handle handle)
prefix_ senf::ppi::module::ActiveSocketSink<Writer>::ActiveSocketSink(Handle handle)
: handle_(handle), event_(handle_, IOEvent::Write), writer_()
: handle_(handle), event_(handle_, IOEvent::Write), writer_()
...
@@ -62,12 +77,30 @@ prefix_ void senf::ppi::module::ActiveSocketSink<Writer>::write()
...
@@ -62,12 +77,30 @@ prefix_ void senf::ppi::module::ActiveSocketSink<Writer>::write()
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// senf::ppi::module::PassiveSocketSink<Writer>
// senf::ppi::module::PassiveSocketSink<Writer>
template <class Writer>
prefix_ senf::ppi::module::PassiveSocketSink<Writer>::PassiveSocketSink()
{
noroute(input);
input.onRequest(&PassiveSocketSink::write);
checkThrottle();
}
template <class Writer>
prefix_ senf::ppi::module::PassiveSocketSink<Writer>::PassiveSocketSink(Writer const & writer)
: writer_ (writer)
{
noroute(input);
input.onRequest(&PassiveSocketSink::write);
checkThrottle();
}
template <class Writer>
template <class Writer>
prefix_ senf::ppi::module::PassiveSocketSink<Writer>::PassiveSocketSink(Handle handle)
prefix_ senf::ppi::module::PassiveSocketSink<Writer>::PassiveSocketSink(Handle handle)
: handle_(handle), writer_()
: handle_(handle), writer_()
{
{
noroute(input);
noroute(input);
input.onRequest(&PassiveSocketSink::write);
input.onRequest(&PassiveSocketSink::write);
checkThrottle();
}
}
template <class Writer>
template <class Writer>
...
@@ -77,6 +110,7 @@ prefix_ senf::ppi::module::PassiveSocketSink<Writer>::PassiveSocketSink(Handle h
...
@@ -77,6 +110,7 @@ prefix_ senf::ppi::module::PassiveSocketSink<Writer>::PassiveSocketSink(Handle h
{
{
noroute(input);
noroute(input);
input.onRequest(&PassiveSocketSink::write);
input.onRequest(&PassiveSocketSink::write);
checkThrottle();
}
}
////////////////////////////////////////
////////////////////////////////////////
...
@@ -88,6 +122,15 @@ prefix_ void senf::ppi::module::PassiveSocketSink<Writer>::write()
...
@@ -88,6 +122,15 @@ prefix_ void senf::ppi::module::PassiveSocketSink<Writer>::write()
writer_(handle_,input());
writer_(handle_,input());
}
}
template <class Writer>
prefix_ void senf::ppi::module::PassiveSocketSink<Writer>::checkThrottle()
{
if (handle_)
input.unthrottle();
else
input.throttle();
}
///////////////////////////////ct.e////////////////////////////////////////
///////////////////////////////ct.e////////////////////////////////////////
#undef prefix_
#undef prefix_
...
...
This diff is collapsed.
Click to expand it.
PPI/SocketSink.cti
+
25
−
1
View file @
4ab18774
...
@@ -39,6 +39,20 @@ prefix_ Writer & senf::ppi::module::ActiveSocketSink<Writer>::writer()
...
@@ -39,6 +39,20 @@ prefix_ Writer & senf::ppi::module::ActiveSocketSink<Writer>::writer()
return writer_;
return writer_;
}
}
template <class Writer>
prefix_ typename senf::ppi::module::ActiveSocketSink<Writer>::Handle
senf::ppi::module::ActiveSocketSink<Writer>::handle()
{
return handle_;
}
template <class Writer>
prefix_ void senf::ppi::module::ActiveSocketSink<Writer>::handle(Handle handle)
{
handle_ = handle;
event_.set(handle_, IOEvent::Write);
}
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// senf::ppi::module::PassiveSocketSink<Writer>
// senf::ppi::module::PassiveSocketSink<Writer>
...
@@ -55,10 +69,20 @@ prefix_ typename Writer::Handle & senf::ppi::module::PassiveSocketSink<Writer>::
...
@@ -55,10 +69,20 @@ prefix_ typename Writer::Handle & senf::ppi::module::PassiveSocketSink<Writer>::
}
}
template <class Writer>
template <class Writer>
prefix_ void senf::ppi::module::PassiveSocketSink<Writer>::
replaceH
andle(Handle handle)
prefix_ void senf::ppi::module::PassiveSocketSink<Writer>::
h
andle(Handle handle)
{
{
handle_ = handle;
handle_ = handle;
checkThrottle();
}
}
#ifndef DOXYGEN
template <class Writer>
prefix_ void senf::ppi::module::PassiveSocketSink<Writer>::replaceHandle(Handle newHandle)
{
handle(newHandle);
}
#endif
///////////////////////////////cti.e///////////////////////////////////////
///////////////////////////////cti.e///////////////////////////////////////
#undef prefix_
#undef prefix_
...
...
This diff is collapsed.
Click to expand it.
PPI/SocketSink.hh
+
40
−
16
View file @
4ab18774
...
@@ -166,7 +166,16 @@ namespace module {
...
@@ -166,7 +166,16 @@ namespace module {
connector
::
ActiveInput
<>
input
;
///< Input connector from which data is received
connector
::
ActiveInput
<>
input
;
///< Input connector from which data is received
ActiveSocketSink
(
Handle
handle
);
///< Create new writer for the given handle
ActiveSocketSink
();
///< Create non-connected writer
/**< The writer will be disabled until a socket is set
\pre Requires \a Writer to be default constructible */
explicit
ActiveSocketSink
(
Writer
const
&
writer
);
///< Create non-connected writer
/**< The writer will be disabled until a socket is set
\pre Requires \a Writer to be copy constructible
\param[in] writer Writer helper writing packet date to
the socket */
explicit
ActiveSocketSink
(
Handle
handle
);
///< Create new writer for the given handle
/**< Data will be written to \a handle using \a Writer.
/**< Data will be written to \a handle using \a Writer.
\pre Requires \a Writer to be default constructible
\pre Requires \a Writer to be default constructible
\param[in] handle Handle to write data to */
\param[in] handle Handle to write data to */
...
@@ -175,10 +184,15 @@ namespace module {
...
@@ -175,10 +184,15 @@ namespace module {
/**< Data will be written to \a handle using \a Writer.
/**< Data will be written to \a handle using \a Writer.
\pre Requires \a Writer to be copy constructible
\pre Requires \a Writer to be copy constructible
\param[in] handle Handle to write data to
\param[in] handle Handle to write data to
\param[in] writer Writer helper writing packet date to the
\param[in] writer Writer helper writing packet date to
socket */
the socket */
Writer
&
writer
();
///< Access the Writer
Handle
handle
();
///< Access handle
void
handle
(
Handle
handle
);
///< Set handle
/**< Assigning an empty or in-valid() handle will disable
the module until a new. valid handle is assigned. */
Writer
&
writer
();
///< Access the Writer
private:
private:
void
write
();
void
write
();
...
@@ -227,7 +241,16 @@ namespace module {
...
@@ -227,7 +241,16 @@ namespace module {
connector
::
PassiveInput
<>
input
;
///< Input connector from which data is received
connector
::
PassiveInput
<>
input
;
///< Input connector from which data is received
PassiveSocketSink
(
Handle
handle
);
///< Create new writer for the given handle
PassiveSocketSink
();
///< Create non-connected writer
/**< The writer will be disabled until a socket is set
\pre Requires \a Writer to be default constructible */
explicit
PassiveSocketSink
(
Writer
const
&
writer
);
///< Create non-connected writer
/**< The writer will be disabled until a socket is set
\pre Requires \a Writer to be copy constructible
\param[in] writer Writer helper writing packet date to
the socket */
explicit
PassiveSocketSink
(
Handle
handle
);
///< Create new writer for the given handle
/**< Data will be written to \a handle using \a Writer.
/**< Data will be written to \a handle using \a Writer.
\pre Requires \a Writer to be default constructible
\pre Requires \a Writer to be default constructible
\param[in] handle Handle to write data to */
\param[in] handle Handle to write data to */
...
@@ -235,22 +258,23 @@ namespace module {
...
@@ -235,22 +258,23 @@ namespace module {
///< Create new writer for the given handle
///< Create new writer for the given handle
/**< Data will be written to \a handle using \a Writer.
/**< Data will be written to \a handle using \a Writer.
\pre Requires \a Writer to be copy constructible
\pre Requires \a Writer to be copy constructible
\param[in] handle Handle to write data to */
\param[in] handle Handle to write data to
\param[in] writer Writer helper writing packet date to
the socket */
Writer
&
writer
();
///< Access the Writer
Handle
&
handle
();
///< Access handle
void
handle
(
Handle
handle
);
///< Set handle
/**< Assigning an empty or in-valid() handle will disable
the module until a new. valid handle is assigned. */
Writer
&
writer
();
///< Access the Writer
#ifndef DOXYGEN
Handle
&
handle
();
/**< Access the handle. This is intendet to be mainly used to reconnect
the underlying socket. */
/* void reconnect(senf::SocketAddress newAddress);
///< Reconnect the handle to which the packets are written
*/
void
replaceHandle
(
Handle
newHandle
);
void
replaceHandle
(
Handle
newHandle
);
/**< Replace the handle to which the packets are written
#endif
* Normally you should access the handle and call connect with
* the new address. This also works for other
* (active) ConnectedSocketSinks/Sources */
private:
private:
void
write
();
void
write
();
void
checkThrottle
();
Handle
handle_
;
Handle
handle_
;
Writer
writer_
;
Writer
writer_
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment