Boost logo

Boost-Commit :

From: stipe_at_[hidden]
Date: 2007-10-26 14:53:11


Author: srajko
Date: 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
New Revision: 40486
URL: http://svn.boost.org/trac/boost/changeset/40486

Log:
add condition, clean up unfused_inherited, add intro signals example
Added:
   sandbox/SOC/2007/signals/boost/dataflow/signal/component/condition.hpp (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/signals/
   sandbox/SOC/2007/signals/libs/dataflow/example/signals/Jamfile.v2 (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/signals/intro_example.cpp (contents, props changed)
   sandbox/SOC/2007/signals/libs/dataflow/example/simple_distributed_example.cpp (contents, props changed)
Text files modified:
   sandbox/SOC/2007/signals/boost/dataflow/signal/component/detail/unfused_inherited.hpp | 52 +++++------------
   sandbox/SOC/2007/signals/boost/dataflow/signal/component/selector.hpp | 88 ++++++++++++++----------------
   sandbox/SOC/2007/signals/boost/dataflow/signal/component/socket_receiver.hpp | 66 ++++++++++++++++++++--
   sandbox/SOC/2007/signals/boost/dataflow/signal/component/socket_sender.hpp | 2
   sandbox/SOC/2007/signals/boost/dataflow/support/port.hpp | 4
   sandbox/SOC/2007/signals/boost/dataflow/support/proxy_port.hpp | 4
   sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/signal_network.xcodeproj/project.pbxproj | 18 +++++
   sandbox/SOC/2007/signals/libs/dataflow/doc/concepts.qbk | 114 ++++++++++++++++++++++++++++++++++++---
   sandbox/SOC/2007/signals/libs/dataflow/doc/dataflow.qbk | 5 +
   sandbox/SOC/2007/signals/libs/dataflow/doc/introduction.qbk | 19 +++++-
   sandbox/SOC/2007/signals/libs/dataflow/doc/port_concepts.qbk | 49 +++++++++++-----
   sandbox/SOC/2007/signals/libs/dataflow/doc/signals.qbk | 2
   sandbox/SOC/2007/signals/libs/dataflow/doc/signals/introduction.qbk | 60 ++------------------
   sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2 | 8 ++
   sandbox/SOC/2007/signals/libs/dataflow/example/VTK/support.hpp | 18 +++---
   sandbox/SOC/2007/signals/libs/dataflow/example/simple_example.cpp | 13 +---
   sandbox/SOC/2007/signals/libs/dataflow/test/signals/test_socket.cpp | 23 ++++++-
   sandbox/SOC/2007/signals/libs/dataflow/test/test_proxy_port.cpp | 4
   18 files changed, 343 insertions(+), 206 deletions(-)

Added: sandbox/SOC/2007/signals/boost/dataflow/signal/component/condition.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/boost/dataflow/signal/component/condition.hpp 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -0,0 +1,58 @@
+// Copyright Stjepan Rajko 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef SIGNAL_NETWORK_CONDITION_HPP
+#define SIGNAL_NETWORK_CONDITION_HPP
+
+#include <boost/dataflow/signal/component/applicator.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
+
+namespace boost { namespace signals {
+
+namespace detail
+{
+ struct cond_and_mutex
+ {
+ boost::condition &c;
+ boost::mutex &m;
+ cond_and_mutex(boost::condition &c, boost::mutex &m)
+ : c(c), m(m)
+ {}
+ };
+
+ struct notify_all
+ {
+ void operator()(cond_and_mutex &cnm)
+ {
+ boost::mutex::scoped_lock lock(cnm.m);
+ cnm.c.notify_all();
+ }
+ };
+} // namespace detail
+
+/** \brief Signals a thread condition when a signal is received.
+*/
+template<typename Signature,
+ typename OutSignal=SIGNAL_NETWORK_DEFAULT_OUT,
+ typename Combiner = boost::last_value<typename boost::function_types::result_type<Signature>::type>,
+ typename Group = int,
+ typename GroupCompare = std::less<Group>
+>
+class condition : public
+ applicator<detail::cond_and_mutex, detail::notify_all, Signature, OutSignal, Combiner, Group, GroupCompare>
+{
+ typedef applicator<detail::cond_and_mutex, detail::notify_all, Signature, OutSignal, Combiner, Group, GroupCompare> base_type;
+public:
+ /** Initializes the internal counter to 0.
+ */
+ condition(boost::condition &cond, boost::mutex &m)
+ : base_type(detail::cond_and_mutex(cond, m))
+ {}
+};
+
+} } // namespace boost::signals
+
+#endif // SIGNAL_NETWORK_CONDITION_HPP

Modified: sandbox/SOC/2007/signals/boost/dataflow/signal/component/detail/unfused_inherited.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/signal/component/detail/unfused_inherited.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/signal/component/detail/unfused_inherited.hpp 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -29,11 +29,8 @@
 #include <boost/fusion/sequence/intrinsic/size.hpp>
 #include <boost/fusion/sequence/container/vector/vector.hpp>
 #include <boost/fusion/sequence/conversion/as_vector.hpp>
-#include <boost/fusion/algorithm/transformation/pop_back.hpp>
 
 #include <boost/fusion/functional/adapter/limits.hpp>
-//#include <boost/fusion/functional/adapter/detail/has_type.hpp>
-//#include <boost/fusion/functional/adapter/detail/nullary_call_base.hpp>
 
 #include <boost/mpl/size.hpp>
 #include <boost/utility/result_of.hpp>
@@ -59,13 +56,13 @@
 
 #define OPERATOR_ARGS BOOST_PP_ITERATION()
 
- template <class Function, class Sequence>
- class unfused_inherited<Function, Sequence,
- typename boost::enable_if<
- boost::mpl::equal_to<
- boost::fusion::result_of::size<Sequence>,
- boost::mpl::int_<OPERATOR_ARGS> >
- >::type >
+ template <class Function, class Sequence>
+ class unfused_inherited<Function, Sequence,
+ typename boost::enable_if<
+ boost::mpl::equal_to<
+ boost::fusion::result_of::size<Sequence>,
+ boost::mpl::int_<OPERATOR_ARGS> >
+ >::type >
     : public Function
     {
     protected:
@@ -97,12 +94,9 @@
             unfused_inherited(const T1 &t1, const T2 &t2)
             : Function(t1, t2)
         { }
-
-/* template<typename F, typename Enable=void>
- struct result;*/
         
         template<typename F>
- struct result//<F>
+ struct result
             : public Function::template result<F> {};
         
         template<typename F>
@@ -111,11 +105,14 @@
             typedef typename boost::result_of<Function(const arg_vector_t &)>::type type;
         };
 
-#if OPERATOR_ARGS>0
         inline typename boost::result_of<Function(const arg_vector_t &)>::type
         operator()(BOOST_PP_ENUM(OPERATOR_ARGS,M,arg_vector_t)) const
         {
- arg_vector_t arg(BOOST_PP_ENUM_PARAMS(OPERATOR_ARGS,a));
+ arg_vector_t arg
+#if OPERATOR_ARGS>0
+ (BOOST_PP_ENUM_PARAMS(OPERATOR_ARGS,a))
+#endif
+ ;
             return Function::operator()(arg);
         }
 
@@ -123,30 +120,15 @@
         inline typename boost::result_of<Function(const arg_vector_t &)>::type
         operator()(BOOST_PP_ENUM(OPERATOR_ARGS,M,arg_vector_t))
         {
- arg_vector_t arg(BOOST_PP_ENUM_PARAMS(OPERATOR_ARGS,a));
- return Function::operator()(arg);
- }
+ arg_vector_t arg
+#if OPERATOR_ARGS>0
+ (BOOST_PP_ENUM_PARAMS(OPERATOR_ARGS,a))
 #endif
-
-#else // OPERATOR_ARGS==0
- inline typename boost::result_of<Function(const arg_vector_t &)>::type
- operator()() const
- {
- arg_vector_t arg;
- return Function::operator()(arg);
- }
-
-#if !BOOST_WORKAROUND(BOOST_MSVC, < 1400)
- inline typename boost::result_of<Function(const arg_vector_t &)>::type
- operator()()
- {
- arg_vector_t arg;
+ ;
             return Function::operator()(arg);
         }
 #endif
 
-#endif // OPERATOR_ARGS>0
-
 #undef M
 #undef MT
 

Modified: sandbox/SOC/2007/signals/boost/dataflow/signal/component/selector.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/signal/component/selector.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/signal/component/selector.hpp 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -1,61 +1,57 @@
-// selector.hpp
-
 // Copyright Stjepan Rajko 2007. Use, modification and
 // distribution is subject to the Boost Software License, Version
 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef SIGNAL_NETWORK_SELECTOR_HPP
-#define SIGNAL_NETWORK_SELECTOR_HPP
+#ifndef SIGNAL_NETWORK_MULTIPLEXER_HPP
+#define SIGNAL_NETWORK_MULTIPLEXER_HPP
 
-#include <boost/dataflow/signal/filter.hpp>
-#include <boost/dataflow/signal/detail/defines.hpp>
+#include <boost/dataflow/signal/component/conditional.hpp>
 
-SIGNAL_NETWORK_OPEN_SIGNET_NAMESPACE
-/** \brief Allows selection of signals from multiple inputs.
-\param Signature Signature of the signal sent and received.
-\warning Since I can't get Doxygen to unravel the preprocessed definition of this
-class, the documentation was generated through a non-functioning class Doxygen could read.
-
-This can be used to determine which signal out of a group of signals
-will continue through the selector (the others will not be forwarded).
-
-\par Example:
-\dontinclude example.cpp
-\skip selector_test
-\until end void selector_test
-*/
+namespace boost { namespace signals {
 
-/*
-template<typename Signature>
-class selector : public fused_filter<Signature>
+namespace detail
 {
- selector() : selected(0) {}
-
- /// Selects the indicated input (if source is 0, no input will be selected).
- void select(int source) {selected = source;}
-
- template <class Seq>
- struct result
+ template<typename T>
+ struct multiplex
     {
- typedef typename boost::function_traits<Signature>::result_type type;
+ T operator ()(T t) const
+ {
+ return t;
+ }
     };
- /// If N is selected, the signal received at this slot will be forwared.
- typename boost::function_traits<Signature>::result_type
- operator()(const VecPar &vec_par)
+}
+
+/** \brief Forwards a single signal to multiple slots, and can
+also be disabled to stop the flow of signals.
+ junction is a conditional with Condition identity and Member volatile bool
+*/
+template<typename Signature,
+ typename OutSignal=SIGNAL_NETWORK_DEFAULT_OUT,
+ typename Combiner = boost::last_value<typename boost::function_types::result_type<Signature>::type>,
+ typename Group = int,
+ typename GroupCompare = std::less<Group>
+>
+class multiplexer : public conditional<int, detail::<bool>, Signature, OutSignal, Combiner, Group, GroupCompare>
+{
+protected:
+ typedef conditional<volatile bool, detail::identity<bool>, Signature, OutSignal, Combiner, Group, GroupCompare> base_type;
+public:
+
+ /** Initializes the junction to be enabled.
+ */
+ junction(bool enabled=true)
     {
- if (selected == n)
- return static_cast<typename boost::function_traits<Signature>::result_type>
- (fused_out(vec_par));
+ enable();
     }
- /// Returns the slot selector for inputN.
- template<int N>
- slot_selector_t<selector<Signature>, Signature> slot()
- {return slot_selector<Signature>(*this, &selector_impl<_inputs, Signature, _arity>::input##n);}
-private:
- volatile int selected;
+ /** Enables the junction (signals will be forwarded).
+ */
+ void enable() {base_type::member = true;}
+ /** Disables the junction (signals will not be forwarded).
+ */
+ void disable() {base_type::member = false;}
 };
-*/
-SIGNAL_NETWORK_CLOSE_SIGNET_NAMESPACE
 
-#endif // SIGNAL_NETWORK_SELECTOR_HPP
+} } // namespace boost::signals
+
+#endif
\ No newline at end of file

Modified: sandbox/SOC/2007/signals/boost/dataflow/signal/component/socket_receiver.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/signal/component/socket_receiver.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/signal/component/socket_receiver.hpp 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -34,25 +34,75 @@
 
 public:
     /// Initializes the socket_sender to use the provided socket.
- socket_receiver(asio::ip::tcp::socket &socket) :
+ socket_receiver(asio::ip::tcp::socket &socket) :
                 socket_(socket),
                 stream(std::ios::in | std::ios::out | std::ios::binary) {}
     /// Sets the receiver to wait for a packet and send its contents via the signal.
         void operator()()
         {
- int received_size = socket_.receive(asio::buffer(buffer, bufferSize));
- stream.str(empty_string);
- stream.write((char *)buffer, received_size);
- boost::archive::binary_iarchive archive(stream);
- archive & base_type::stored();
- base_type::send();
+ uint32_t packet_size;
+ boost::asio::read(socket_, asio::buffer(&packet_size, 4));
+ process_buffer(socket_.receive(asio::buffer(buffer, packet_size)));
         }
-
+ void async_read()
+ {
+ boost::asio::async_read(
+ socket_,
+ asio::buffer(&packet_size, 4),
+ boost::bind(
+ &socket_receiver::async_read_header,
+ this,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred));
+ }
 private:
+ void async_read_header(const boost::system::error_code& error, size_t bytes_transferred)
+ {
+ if (!error)
+ {
+ boost::asio::async_read(
+ socket_,
+ asio::buffer(buffer, packet_size),
+ boost::bind(
+ &socket_receiver::async_read_signal,
+ this,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred));
+ }
+ else
+ {
+ // unless socket has been closed, throw the error
+ if (error != boost::asio::error::eof)
+ throw boost::system::system_error(error);
+ }
+ }
+
+ void async_read_signal(const boost::system::error_code& error, size_t bytes_transferred)
+ {
+ if (!error)
+ {
+ process_buffer(bytes_transferred);
+ // prepare next read
+ async_read();
+ }
+ else
+ throw boost::system::system_error(error);
+ }
+
+ void process_buffer(size_t bytes_transferred)
+ {
+ stream.str(empty_string);
+ stream.write((char *)buffer, bytes_transferred);
+ boost::archive::binary_iarchive archive(stream);
+ archive & base_type::stored();
+ base_type::send();
+ }
+
         asio::ip::tcp::socket &socket_;
         std::stringstream stream;
         std::string empty_string;
         boost::archive::binary_iarchive *archive;
+ uint32_t packet_size;
         enum { bufferSize = 20000 };
         unsigned char buffer[bufferSize];
 };

Modified: sandbox/SOC/2007/signals/boost/dataflow/signal/component/socket_sender.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/signal/component/socket_sender.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/signal/component/socket_sender.hpp 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -39,6 +39,8 @@
         {
             boost::archive::binary_oarchive archive (stream);
             archive & vec_par;
+ uint32_t packet_size=stream.str().size();
+ boost::asio::write(socket, asio::buffer(&packet_size, 4));
             boost::asio::write(socket, asio::buffer(stream.str()),
                 boost::asio::transfer_all());
             stream.str(empty_string);

Modified: sandbox/SOC/2007/signals/boost/dataflow/support/port.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/support/port.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/port.hpp 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -198,7 +198,7 @@
 } } // namespace boost::dataflow
 
 /// Macro simplifying non-intrusive specification of a type's PortTraits.
-#define DATAFLOW_PORT_CATEGORY(Type,PortTraits) \
+#define DATAFLOW_PORT_TRAITS(Type,PortTraits) \
 namespace boost { namespace dataflow { \
 template<> \
 struct port_traits_of< \
@@ -213,7 +213,7 @@
 
 /// Macro simplifying non-intrusive specification of multiple types'
 /// PortTraits, using a boost::enable_if condition.
-#define DATAFLOW_PORT_CATEGORY_ENABLE_IF(Type,Cond,PortTraits) \
+#define DATAFLOW_PORT_TRAITS_ENABLE_IF(Type,Cond,PortTraits) \
 namespace boost { namespace dataflow { \
 template<typename Type> \
 struct port_traits_of< \

Modified: sandbox/SOC/2007/signals/boost/dataflow/support/proxy_port.hpp
==============================================================================
--- sandbox/SOC/2007/signals/boost/dataflow/support/proxy_port.hpp (original)
+++ sandbox/SOC/2007/signals/boost/dataflow/support/proxy_port.hpp 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -174,7 +174,7 @@
 
 } } // namespace boost::dataflow
 
-#define DATAFLOW_PROXY_PORT_CATEGORY(ProxyPort,ProxyPortCategory) \
+#define DATAFLOW_PROXY_PORT_TRAITS(ProxyPort,ProxyPortCategory) \
 namespace boost { namespace dataflow { \
 template<> \
 struct proxy_port_traits_of< \
@@ -187,7 +187,7 @@
 }; \
 }}
 
-#define DATAFLOW_PROXY_PORT_CATEGORY_ENABLE_IF(P,Cond,ProxyPortCategory) \
+#define DATAFLOW_PROXY_PORT_TRAITS_ENABLE_IF(P,Cond,ProxyPortCategory) \
 namespace boost { namespace dataflow { \
 template<typename P> \
 struct proxy_port_traits_of< \

Modified: sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/signal_network.xcodeproj/project.pbxproj
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/signal_network.xcodeproj/project.pbxproj (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/build/xcodeide/signal_network.xcodeproj/project.pbxproj 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -88,7 +88,7 @@
                 083FD3C10C62A75B00EF3F6B /* concepts.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = concepts.qbk; sourceTree = "<group>"; };
                 083FD3C60C62A7F600EF3F6B /* phoenix.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = phoenix.qbk; sourceTree = "<group>"; };
                 084482560CA0B37200B88137 /* operators.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = operators.hpp; sourceTree = "<group>"; };
- 08668C4E0C19A16300ACB19A /* example.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = example.cpp; sourceTree = "<group>"; };
+ 08668C4E0C19A16300ACB19A /* simple_distributed_example.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = simple_distributed_example.cpp; sourceTree = "<group>"; };
                 08668C4F0C19A16300ACB19A /* Jamfile.v2 */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = Jamfile.v2; sourceTree = "<group>"; };
                 08B9D4190CC3D0790050F10B /* test_binary_op.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = test_binary_op.cpp; sourceTree = "<group>"; };
                 08B9D41E0CC3D0A80050F10B /* my_producer_consumer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = my_producer_consumer.hpp; sourceTree = "<group>"; };
@@ -194,6 +194,9 @@
                 08F71D500CA3547C0010099E /* test_storage.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = test_storage.cpp; sourceTree = "<group>"; };
                 08F9459A0C46A86E00E224E4 /* components.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = components.hpp; sourceTree = "<group>"; };
                 08F9462E0C46C2F000E224E4 /* fibonacci.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fibonacci.cpp; sourceTree = "<group>"; };
+ 08F98B400CD0190A009D642B /* Jamfile.v2 */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = Jamfile.v2; sourceTree = "<group>"; };
+ 08F98B470CD01963009D642B /* intro_example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = intro_example.cpp; sourceTree = "<group>"; };
+ 08F995660CCFC68F001184CE /* condition.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = condition.hpp; sourceTree = "<group>"; };
                 08FA6A050C41E11800434913 /* rationale.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rationale.qbk; sourceTree = "<group>"; };
                 08FB7BEF0C6157D000BD4EC2 /* introduction.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = introduction.qbk; sourceTree = "<group>"; };
                 08FB7BFE0C61597000BD4EC2 /* signals.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = signals.qbk; sourceTree = "<group>"; };
@@ -248,8 +251,9 @@
                 08668C4D0C19A16300ACB19A /* example */ = {
                         isa = PBXGroup;
                         children = (
+ 08F98B3F0CD018E7009D642B /* signals */,
                                 0800AC2F0C8CA99700994538 /* VTK */,
- 08668C4E0C19A16300ACB19A /* example.cpp */,
+ 08668C4E0C19A16300ACB19A /* simple_distributed_example.cpp */,
                                 08668C4F0C19A16300ACB19A /* Jamfile.v2 */,
                                 08EFED440C1CD55100097C80 /* timing_example.cpp */,
                                 08FC26060C46049400F59CDD /* edit_distance.cpp */,
@@ -311,6 +315,7 @@
                                 08EF9B350C5D506A00D4D206 /* socket_sender.hpp */,
                                 08EF9B360C5D506A00D4D206 /* storage.hpp */,
                                 08EF9B370C5D506A00D4D206 /* timed_generator.hpp */,
+ 08F995660CCFC68F001184CE /* condition.hpp */,
                         );
                         path = component;
                         sourceTree = "<group>";
@@ -486,6 +491,15 @@
                         path = signals;
                         sourceTree = "<group>";
                 };
+ 08F98B3F0CD018E7009D642B /* signals */ = {
+ isa = PBXGroup;
+ children = (
+ 08F98B400CD0190A009D642B /* Jamfile.v2 */,
+ 08F98B470CD01963009D642B /* intro_example.cpp */,
+ );
+ path = signals;
+ sourceTree = "<group>";
+ };
                 08FB7BEE0C6157AE00BD4EC2 /* signals */ = {
                         isa = PBXGroup;
                         children = (

Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/concepts.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/concepts.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/concepts.qbk 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -45,9 +45,9 @@
 the same type of mechanism) can typically be connected/disconnected, or data
 can be extracted from one port to another.
 
-Depending on the data-transport mechanism used, a producer could be anything
+Depending on the data-transport mechanism used, a producer port could be anything
 that produces / provides data: a POD variable, an object of a class type, or
-a function that returns a value. Similarly, a consumer could be anything
+a function that returns a value. Similarly, a consumer port could be anything
 that consumes data - a function that takes an argument, a functor, etc.
 
 Ports are captured more formally by the [PortConcept] concept.
@@ -111,14 +111,14 @@
 
 [heading Invocation]
 
-Another important thing to note is that there is a separation between providing
+[/Another important thing to note is that there is a separation between providing
 the data to a component, and invoking the component. In some cases, the two
 happen simoultaneously (when the data is passed and returned via a function
 call), while in others invoking the computational element can happen
 separately from providing the data (at least from a modeling perspective).
 An example of the latter is a consumer which uses data stored in
 a particular location. We can place the data in that location much before
-invoking the consumer.
+invoking the consumer.]
 
 We will call /invoking/ a component (producer or consumer) the action of
 causing it to consume data from connected producers, and producing data
@@ -126,13 +126,23 @@
 
 Invocation is captured more formally by the [InvocableConcept] concept.
 
-[/An invocation is /forwarding/
-if it causes the invoked producer to also invoke the consumer, or if it causes
-the invoked consumer to invoke the producer.]
 
 
 [section Mechanism]
 
+[note The Mechanism concept currently has no requirements.]
+
+A Mechanism type is used to specify the mechanism when specializing or invoking
+Dataflow templates. Each mechanism therefore has a corresponding
+type tag.
+
+[heading Examples]
+
+The following code declares the [VTK] mechanism tag - it is a part of
+the [vtk_example example showing how to provide a VTK support layer].
+
+[vtk_mechanism]
+
 [endsect][/mechanism]
 
 [include port_concepts.qbk]
@@ -236,6 +246,92 @@
 
 [endsect][/unaryoperable]
 
+[section ComponentTraits]
+
+A ['[ComponenTraitsConcept]] specifies the traits of a [ComponentConcept].
+
+[heading Notation]
+[variablelist
+ [[CT] [A ComponentTraits type.]]
+ [[C] [A [ComponentConcept] type of traits `CT`.]]
+]
+
+[heading Requirements]
+[table
+ [[Name] [Expression] [Result Type] [Semantics]]
+ [
+ [Mechanism]
+ [`PC::mechanism`]
+ [any type]
+ [[MechanismConcept] type tag.]
+ ]
+]
+
+[heading Header]
+
+```
+ #include <boost/dataflow/support/component.hpp> // or
+ #include <boost/dataflow/support.hpp>
+```
+
+[heading Notes]
+
+[heading Examples]
+
+[endsect][/componenttraits]
+
+
+[section Component]
+
+A type `C` is a ['[ComponentConcept]] for a mechanism `M`
+if it specifies a [ComponentTraitsConcept] for that mechanism.
+
+[heading Refinements]
+
+[heading Notation]
+The following expressions are used in this document:
+
+[variablelist
+ [[C] [A Component type.]]
+ [[M] [A [MechanismConcept] type.]]
+]
+
+[heading Requirements]
+[table
+ [[Name] [Expression] [Result Type] [Semantics]]
+ [
+ [Component Traits]
+ [`component_traits_of<M, C>::type`]
+ [Any [ComponentTraitsConcept] type]
+ [
+ The [ComponentTraitsConcept] of the port.
+ ]
+ ]
+ [
+ [IsComponent Trait]
+ [`is_component<M, C>::type`]
+ [Boolean metafunction that evaluates to true]
+ [
+ A trait encapsulating adherence to the Component
+ concept.
+ ]
+ ]
+]
+
+[heading Header]
+
+```
+ #include <boost/dataflow/support/component.hpp> // or
+ #include <boost/dataflow/support.hpp>
+```
+
+[heading Notes]
+
+[heading Examples]
+
+[endsect][/component]
+
+
 [section:componentoperable ComponentOperable (Invocable) ]
 
 A [ComponentConcept] `P` is /ComponentOperable/
@@ -268,6 +364,6 @@
     ]
 ]
 
-[endsect][/unaryoperable]
+[endsect][/componentoperable]
 
-[endsect][/concepts]
\ No newline at end of file
+[endsect][/concepts]

Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/dataflow.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/dataflow.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/dataflow.qbk 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -43,6 +43,7 @@
 [template PhoenixProducerConcept[] [link dataflow.concepts.phoenix.phoenixproducer [^PhoenixProducer]]]
 [template PhoenixConsumerConcept[] [link dataflow.concepts.phoenix.phoenixproducer [^PhoenixConsumer]]]
 
+[template vtk_example[text] [link dataflow.introduction.examples.new_layer [text]]]
 [template how_to_use[text] [link dataflow.introduction.how_to_use [text]]]
 [template DataflowSignals[] [link dataflow.signals Dataflow.Signals]]
 [template DataflowPhoenix[] [link dataflow.phoenix Dataflow.Phoenix]]
@@ -111,6 +112,8 @@
 
 [import ../example/fibonacci.cpp]
 [import ../example/simple_example.cpp]
+[import ../example/simple_distributed_example.cpp]
+[import ../example/signals/intro_example.cpp]
 
 [import ../example/VTK/support.hpp]
 
@@ -143,7 +146,7 @@
 
 [include concepts.qbk]
 
-[include components.qbk]
+[/[include components.qbk]]
 
 [include signals.qbk]
 

Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/introduction.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/introduction.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/introduction.qbk 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -554,10 +554,19 @@
 [link dataflow.introduction.dataflow motivation section] to a dataflow
 network that straddles a network socket:
 
-[*insert example....]
-
+[simple_distributed_example]
 
+A sample run produces:
 
+[pre
+0.213436
+-0.49558
+1.57538
+-1.0592
+1.83927
+1.88577
+...
+]
 
 [endsect][/distributed]
 
@@ -565,13 +574,15 @@
 
 [section:linking How to link]
 
-The generic Dataflow support layer is header-only, and relies only on a few
+The generic Dataflow support layer is header-only, and relies only on other
 Boost header-only libraries (MPL, enable_if, and small parts of fusion).
 
 The [DataflowSignals] layer is dependent on the [BoostSignals] library,
 which must be built and linked. A few of the components ([socket_sender]
 and [socket_receiver]) are also dependent on [BoostAsio], which depends on
-the System library which must also be built and linked.
+the System library which must also be built and linked. A few other components
+([mutex] and [condition]) are dependent on [BoostThreads], which has to be
+linked as well.
 
 [endsect][/linking]
 

Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/port_concepts.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/port_concepts.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/port_concepts.qbk 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -3,14 +3,16 @@
 A [PortCategoryConcept] designates a category of port in the Dataflow library.
 The library currently defines two [PortCategoryConcept]s:
 
- * `boost::dataflow::ports::producer`, and
- * `boost::dataflow::ports::consumer`
+* `boost::dataflow::ports::producer`, and
+* `boost::dataflow::ports::consumer`.
+
+For a higher-level overview of the concepts, see the [concepts] introduction.
 
 [heading Notation]
 The following expressions are used in this document:
 
 [variablelist
- [[PT] [A [PortCategoryConcept] type.]]
+ [[PC] [A [PortCategoryConcept] type.]]
 ]
 
 [heading Requirements]
@@ -19,18 +21,22 @@
     [[Name] [Expression] [Result Type] [Description]]
     [
         [Opposite PortCategory]
- [`PT::complement`]
+ [`PC::complement`]
         [[PortCategoryConcept] type]
         [
- The complementing [PortCategoryConcept] of `PT`, meaning that connections
- can be made between [PortCategoryConcept]s of [PortCategoryConcept] `PT` and
- [PortConcept]s of [PortCategoryConcept] `PT::complement`.
+ The complementing [PortCategoryConcept] of `PC`, meaning that it
+ is possible to make connections between [PortConcept]s of
+ [PortCategoryConcept] `PC` and [PortConcept]s of
+ [PortCategoryConcept] `PC::complement`.
         ]
     ]
 ]
 
 [heading Header]
 
+The types, templates, and functions shown here are declared in the following
+files:
+
 ```
     #include <boost/dataflow/support/port.hpp> // or
     #include <boost/dataflow/support.hpp>
@@ -45,7 +51,7 @@
 [heading Notation]
 [variablelist
     [[PC] [A PortTraits type.]]
- [[P] [A [PortConcept] type of producer category `PC`.]]
+ [[P] [A [PortConcept] type with port traits `PC`.]]
 ]
 
 [heading Requirements]
@@ -72,6 +78,8 @@
 ]
 
 [heading Header]
+The types, templates, and functions shown here are declared in the following
+files:
 
 ```
     #include <boost/dataflow/support/port.hpp> // or
@@ -82,7 +90,13 @@
 
 [heading Examples]
 
-[endsect][/producertraits]
+The following code defines a port traits type for vtk_algorithm_output,
+and associates it with this type. It is a part of
+the [vtk_example example showing how to provide a VTK support layer].
+
+[vtk_algorithm_output_producer]
+
+[endsect][/porttraits]
 
 
 [section:port Port (ProducerPort, ConsumerPort)]
@@ -92,12 +106,11 @@
 
 In that case,
 
-* If `PC` is `ports::producer`, then `P` is a `ProducerPort`
-* If `PC` If `ports::consumer`, then `P` is a `ConsumerPort`
+* If `PC` is `ports::producer`, then `P` is a [ProducerPortConcept]
+* If `PC` If `ports::consumer`, then `P` is a [ConsumerPortConcept]
 
 [heading Refinements]
-* [SingleTypePort]
-* [PhoenixPortConcept]
+
 
 [heading Notation]
 The following expressions are used in this document:
@@ -113,8 +126,7 @@
     [[Name] [Expression] [Result Type] [Semantics]]
     [
         [Port Traits]
- [`port_traits_of<M, PC, P>::type`
- [footnote `namespace boost::dataflow`]]
+ [`port_traits_of<M, PC, P>::type`]
         [Any [PortTraitsConcept] type]
         [
             The [PortTraitsConcept] of the port.
@@ -122,8 +134,7 @@
     ]
     [
         [IsPort Trait]
- [`is_port<M, PC, P>::type`
- [footnote `namespace boost::dataflow`]]
+ [`is_port<M, PC, P>::type`]
         [Boolean metafunction that evaluates to true]
         [
             A trait encapsulating adherence to the Port
@@ -133,6 +144,8 @@
 ]
 
 [heading Header]
+The types, templates, and functions shown here are declared in the following
+files:
 
 ```
     #include <boost/dataflow/support/port.hpp> // or
@@ -207,6 +220,8 @@
 ]
 
 [heading Header]
+The types, templates, and functions shown here are declared in the following
+files:
 
 ```
     #include <boost/dataflow/support/proxy_port.hpp> // or

Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/signals.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/signals.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/signals.qbk 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -2,7 +2,7 @@
 
 [include signals/introduction.qbk]
 
-[include signals/concepts.qbk]
+[/[include signals/concepts.qbk]]
 
 [include signals/connections.qbk]
 

Modified: sandbox/SOC/2007/signals/libs/dataflow/doc/signals/introduction.qbk
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/doc/signals/introduction.qbk (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/doc/signals/introduction.qbk 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -101,10 +101,7 @@
 create a simple network using
 [funcref boost::dataflow::operator>>=() operator>>=]:
         
-[table storage class use example
- [[fused][unfused]]
- [[[test_storage_fused]][[test_storage_unfused]]]
-]
+[test_storage_unfused]
 
 [heading Creating your own signal receiver (slot)]
 
@@ -117,66 +114,25 @@
 A class that can receive signals of such a signature would be
 defined as follows:
 
- class SignalVoidCounter
- {
- int cnt;
- public:
- // For now, we must also declare the consumer category and result type.
- // This requirement will go away.
- typedef dataflow::signal_consumer consumer_category;
- typedef void result_type;
-
- SignalVoidCounter() : cnt(0) {}
- void operator()()
- {
- cnt++; // whenever a void() signal is received, increase the counter
- }
- int GetCount()
- {
- return cnt;
- }
- }; // end class SignalVoidCounter
+[signal_void_counter]
 
 The above class does something really simple - it receives signals of
 signature `void()`, and counts how many it has received. While this
 functionality is actually covered by the library component [counter],
 it's a good introductory example.
 
+You can now introduce this component into a signal network:
+
+[signal_void_counter_main]
+
 If you read the section about [link dataflow.introduction.fusion Boost.Fusion],
 you will find out that the [DataflowSignals] library works with both
 /fused/ and /unfused/ signals. If you wanted the above to work with
 fused signals, all you would need to do is add or substitute the following
 `operator()`:
 
- void operator()(const fusion::vector<> &)
- {
- cnt++; // whenever a void() signal is received, increase the counter
- }
-
-You can now introduce this component into a signal network:
-
-[table storage class use example
- [[fused][unfused]]
- [[``
- SignalVoidCounter counter;
- signals::storage<void(), signals::unfused> storage;
-
- storage >>= counter;
- for (int i=0; i<33; i++)
- invoke(storage);
-
- assert(counter.GetCount());
- ``][``
- SignalVoidCounter counter;
- signals::storage<void(), signals::fused> storage;
-
- storage >>= counter;
- for (int i=0; i<33; i++)
- invoke(storage);
-
- assert(counter.GetCount());
- ``]]
-]
+[fused_signal_void_counter]
+[fused_signal_void_counter_main]
 
 To proceed, you may want to look at
 

Modified: sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2 (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/Jamfile.v2 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -4,6 +4,7 @@
 # http://www.boost.org/LICENSE_1_0.txt)
 
 build-project VTK ;
+build-project signals ;
 
 project dataflow/example
     : requirements
@@ -12,9 +13,12 @@
       <define>BOOST_ALL_NO_LIB=1
     ;
 
-exe example : example.cpp ;
 # exe timing_example : timing_example.cpp ;
 #exe edit_distance : edit_distance.cpp ;
 #exe fibonacci : fibonacci.cpp ;
-#exe simple_example : simple_example.cpp /boost/thread//boost_thread/<link>static ;
+exe simple_example : simple_example.cpp /boost/thread//boost_thread/<link>static ;
+exe simple_distributed_example : simple_distributed_example.cpp
+ /boost/serialization//boost_serialization/<link>static
+ /boost/thread//boost_thread/<link>static
+ /boost/system//boost_system/<link>static ;
 

Modified: sandbox/SOC/2007/signals/libs/dataflow/example/VTK/support.hpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/VTK/support.hpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/VTK/support.hpp 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -46,7 +46,7 @@
 // PortTraits, and also verifies that the PortTraits requirements are satisfied.
 // The port_traits_of template is used by the Dataflow library to associate
 // a Port with its PortTraits.
-DATAFLOW_PORT_CATEGORY(vtkAlgorithmOutput, vtk::vtk_algorithm_output_producer)
+DATAFLOW_PORT_TRAITS(vtkAlgorithmOutput, vtk::vtk_algorithm_output_producer)
 //]
 
 
@@ -60,7 +60,7 @@
 
 // Since vtkAlgorithm is typically inherited, we will specialize the
 // port_traits_of template for all its descendants.
-DATAFLOW_PORT_CATEGORY_ENABLE_IF(
+DATAFLOW_PORT_TRAITS_ENABLE_IF(
     T,
     boost::is_base_of<vtkAlgorithm BOOST_PP_COMMA() T>,
     vtk::vtk_algorithm_consumer)
@@ -109,7 +109,7 @@
 
 } } } // namespace boost::dataflow::vtk
 
-DATAFLOW_PROXY_PORT_CATEGORY_ENABLE_IF(
+DATAFLOW_PROXY_PORT_TRAITS_ENABLE_IF(
     T,
     mpl::and_<
         boost::is_base_of<vtkAlgorithm BOOST_PP_COMMA() T> BOOST_PP_COMMA()
@@ -152,12 +152,12 @@
 
 } } } // namespace boost::dataflow::vtk
 
-DATAFLOW_PORT_CATEGORY_ENABLE_IF(
+DATAFLOW_PORT_TRAITS_ENABLE_IF(
     T,
     boost::is_base_of<vtkActor BOOST_PP_COMMA() T>,
     vtk::vtk_actor_producer)
 
-DATAFLOW_PORT_CATEGORY_ENABLE_IF(
+DATAFLOW_PORT_TRAITS_ENABLE_IF(
     T,
     boost::is_base_of<vtkActor BOOST_PP_COMMA() T>,
     vtk::vtk_actor_consumer)
@@ -192,7 +192,7 @@
     
 } } } // namespace boost::dataflow::vtk
 
-DATAFLOW_PROXY_PORT_CATEGORY_ENABLE_IF(
+DATAFLOW_PROXY_PORT_TRAITS_ENABLE_IF(
     T,
     boost::is_base_of<vtkMapper BOOST_PP_COMMA() T>,
     vtk::vtk_mapper_proxy_producer)
@@ -267,17 +267,17 @@
 
 } } } // namespace boost::dataflow::vtk
 
-DATAFLOW_PORT_CATEGORY_ENABLE_IF(
+DATAFLOW_PORT_TRAITS_ENABLE_IF(
     T,
     boost::is_base_of<vtkRenderer BOOST_PP_COMMA() T>,
     vtk::vtk_renderer_producer)
 
-DATAFLOW_PORT_CATEGORY_ENABLE_IF(
+DATAFLOW_PORT_TRAITS_ENABLE_IF(
     T,
     boost::is_base_of<vtkRenderer BOOST_PP_COMMA() T>,
     vtk::vtk_renderer_consumer)
 
-DATAFLOW_PORT_CATEGORY_ENABLE_IF(
+DATAFLOW_PORT_TRAITS_ENABLE_IF(
     T,
     boost::is_base_of<vtkRenderWindow BOOST_PP_COMMA() T>,
     vtk::vtk_rendererwindow_consumer)

Added: sandbox/SOC/2007/signals/libs/dataflow/example/signals/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/signals/Jamfile.v2 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -0,0 +1,14 @@
+# Copyright 2007 Stjepan Rajko.
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+project dataflow/example/signals
+ : requirements
+ <include>../../..
+ <library>/boost/signals//boost_signals/<link>static
+ <define>BOOST_ALL_NO_LIB=1
+ ;
+
+exe intro_example : intro_example.cpp ;
+

Added: sandbox/SOC/2007/signals/libs/dataflow/example/signals/intro_example.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/signals/intro_example.cpp 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -0,0 +1,78 @@
+// Copyright 2007 Stjepan Rajko.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/dataflow/signal/component/storage.hpp>
+#include <boost/dataflow/signal/connection.hpp>
+
+using namespace boost;
+
+//[ signal_void_counter
+class SignalVoidCounter
+{
+ int cnt;
+public:
+ typedef dataflow::signals::keyed_consumer port_traits;
+
+ SignalVoidCounter() : cnt(0) {}
+ void operator()()
+ {
+ cnt++; // whenever a void() signal is received, increase the counter
+ }
+ int GetCount()
+ {
+ return cnt;
+ }
+}; // end class SignalVoidCounter
+//]
+
+//[ fused_signal_void_counter
+class FusedSignalVoidCounter
+{
+ int cnt;
+public:
+ typedef dataflow::signals::keyed_consumer port_traits;
+
+ FusedSignalVoidCounter() : cnt(0) {}
+ void operator()(const fusion::vector<> &)
+ {
+ cnt++; // whenever a void(const fusion::vector<> &) signal is received, increase the counter
+ }
+ int GetCount()
+ {
+ return cnt;
+ }
+}; // end class SignalVoidCounter
+//]
+
+int main(int, char* [])
+{
+{
+//[ signal_void_counter_main
+ SignalVoidCounter counter;
+ signals::storage<void(), signals::unfused> storage;
+
+ storage >>= counter;
+ for (int i=0; i<33; i++)
+ invoke(storage);
+
+ assert(counter.GetCount() == 33);
+//]
+}
+{
+//[ fused_signal_void_counter_main
+ FusedSignalVoidCounter counter;
+ signals::storage<void(), signals::fused> storage;
+
+ storage >>= counter;
+ for (int i=0; i<33; i++)
+ invoke(storage);
+
+ assert(counter.GetCount() == 33);
+//]
+}
+ return 0;
+}
+
+

Added: sandbox/SOC/2007/signals/libs/dataflow/example/simple_distributed_example.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/simple_distributed_example.cpp 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -0,0 +1,136 @@
+// Copyright Stjepan Rajko 2007. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+//[ simple_distributed_example
+
+#include <boost/asio.hpp>
+
+#include <boost/dataflow/signal/component/socket_receiver.hpp>
+#include <boost/dataflow/signal/component/socket_sender.hpp>
+#include <boost/dataflow/signal/component/storage.hpp>
+#include <boost/dataflow/signal/component/timed_generator.hpp>
+#include <boost/dataflow/signal/connection.hpp>
+
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/normal_distribution.hpp>
+#include <boost/random/variate_generator.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
+#include <iostream>
+
+using namespace boost;
+
+// This will be our data processor. The signature void(double) designates
+// the output signal (we will be sending out an double). The signals
+// we can receive depend on how we overload operator().
+class processor : public signals::filter<void (double)>
+{
+public:
+ // Initialize the Gaussian noise generator.
+ processor() : generator(mt, dist) {}
+
+ // Receive void(double) signals, add some Gaussian noise, and send
+ // out the modified value.
+ void operator()(double x)
+ {
+ out(x + generator());
+ }
+private:
+ mt19937 mt;
+ normal_distribution<> dist;
+ boost::variate_generator<mt19937&, boost::normal_distribution<> > generator;
+};
+
+// This will be our data output. We just need to make a function object,
+// and specify that it is a signals::keyed_consumer.
+class output
+{
+public:
+ typedef dataflow::signals::keyed_consumer port_traits;
+
+ void operator()(double x)
+ {
+ std::cout << x << std::endl;
+ }
+};
+
+mutex mutex_;
+condition cond;
+asio::io_service io_service;
+
+// This function will set up an asio acceptor, and wait for a connection.
+// Once established, it will set up a signal network which will send
+// its final signal through the socket.
+void asio_server()
+{
+ // set up the socket
+ asio::ip::tcp::acceptor acceptor(io_service, asio::ip::tcp::endpoint(asio::ip::tcp::v4(), 1097));
+ asio::ip::tcp::socket socket(io_service);
+ {
+ boost::mutex::scoped_lock lock(mutex_);
+ acceptor.listen();
+ cond.notify_all();
+ }
+ acceptor.accept(socket);
+
+ // For our data source, we will use timed_generator,
+ // which creates its own thread and outputs it's stored value
+ // at a specified time interval. We'll store a value of 0 to be sent out.
+ // The signature void(double) specifies that the signal carries a double,
+ // and that there is no return value.
+ signals::timed_generator<void (double), signals::unfused> input(0);
+ // To have our dataflow network straddle a network connection,
+ // we need a socket_sender
+ signals::socket_sender<void (double)> sender(socket);
+
+ // create the network
+ input >>= sender;
+
+ // Tell the source to start producing data, every 0.5s:
+ input.enable(0.5);
+
+ // take a little nap :-)
+ boost::xtime xt;
+ boost::xtime_get(&xt, boost::TIME_UTC);
+ xt.sec += 10;
+ boost::thread::sleep(xt);
+
+ input.join();
+}
+
+int main(int, char* [])
+{
+ // start the server in a separate thread, and wait until it is listening
+ boost::mutex::scoped_lock lock(mutex_);
+ boost::thread t(asio_server);
+ cond.wait(lock);
+
+ // set up the socket
+ asio::ip::tcp::endpoint endpoint_recv(asio::ip::address::from_string("127.0.0.1"), 1097);
+ asio::ip::tcp::socket socket(io_service);
+ socket.connect(endpoint_recv);
+
+ // Setup data processor and output:
+ processor proc;
+ output out;
+ signals::socket_receiver<void (double), signals::unfused> receiver(socket);
+
+ // set up the network
+ receiver >>= proc >>= out;
+
+ // start asynchronous receiving
+ receiver.async_read();
+ boost::thread receive_thread(boost::bind(&asio::io_service::run, boost::ref(io_service)));
+
+ // and wait until the server is done sending
+ t.join();
+
+ io_service.stop();
+ receive_thread.join();
+
+ return 0;
+} // int test_main(int, char* [])
+//]

Modified: sandbox/SOC/2007/signals/libs/dataflow/example/simple_example.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/example/simple_example.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/example/simple_example.cpp 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -19,16 +19,12 @@
 // This will be our data processor. The signature void(double) designates
 // the output signal (we will be sending out an double). The signals
 // we can receive depend on how we overload operator().
-// For now, we must also specify a result_type (or result) - this requirement
-// will go away.
 class processor : public signals::filter<void (double)>
 {
 public:
     // Initialize the Gaussian noise generator.
     processor() : generator(mt, dist) {}
     
- typedef void result_type;
-
     // Receive void(double) signals, add some Gaussian noise, and send
     // out the modified value.
     void operator()(double x)
@@ -41,15 +37,12 @@
     boost::variate_generator<mt19937&, boost::normal_distribution<> > generator;
 };
 
-// This will be our data output. We just need to make a function object.
-// For now, we must also give it the appropriate consumer category, and define
-// a result_type (or result) so that Dataflow.Signals knows it is a
-// function object - these requirements will go away.
+// This will be our data output. We just need to make a function object,
+// and specify that it is a signals::keyed_consumer.
 class output
 {
 public:
- typedef dataflow::signal_consumer consumer_category;
- typedef void result_type;
+ typedef dataflow::signals::keyed_consumer port_traits;
     
     void operator()(double x)
     {

Modified: sandbox/SOC/2007/signals/libs/dataflow/test/signals/test_socket.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/test/signals/test_socket.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/test/signals/test_socket.cpp 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -8,6 +8,7 @@
 #include <boost/dataflow/signal/component/socket_receiver.hpp>
 #include <boost/dataflow/signal/component/socket_sender.hpp>
 #include <boost/dataflow/signal/component/function.hpp>
+#include <boost/dataflow/signal/component/condition.hpp>
 #include <boost/dataflow/signal/connection.hpp>
 
 #include <boost/thread/thread.hpp>
@@ -49,11 +50,13 @@
 
         // cause the generator to send it's stored value
         generator.send();
+ // send a second value;
+ add2(2.0f);
 }
 
 int test_main(int, char* [])
 {
- // start the server in a separate thread
+ // start the server in a separate thread, and wait until it is listening
         boost::mutex::scoped_lock lock(mutex_);
         boost::thread t(asio_server);
         cond.wait(lock);
@@ -66,14 +69,26 @@
         // instatiate the components
     signals::socket_receiver<void (float), signals::fused> receiver(socket);
         signals::storage<void (float), signals::fused> collector(0.0f);
+ signals::condition<void (float), signals::fused> receive_condition(cond, mutex_);
 
         // set up the network
         receiver >>= collector;
 
- // this receiver is synchronous - we have to tell it to receive a signal
- receiver();
-
+ // test synchronous receiving first - tell the receiver to receive a signal
+ receiver();
         BOOST_CHECK_EQUAL(collector.at<0>(), 3.0f);
+ receiver >>= receive_condition;
+
+ // now test asynchronous receiving - start the async reading
+ receiver.async_read();
+ boost::thread receive_thread(boost::bind(&asio::io_service::run, boost::ref(io_service)));
+
+ cond.wait(lock);
+
+ BOOST_CHECK_EQUAL(collector.at<0>(), 4.0f);
+
+ io_service.stop();
+ receive_thread.join();
 
         t.join();
 

Modified: sandbox/SOC/2007/signals/libs/dataflow/test/test_proxy_port.cpp
==============================================================================
--- sandbox/SOC/2007/signals/libs/dataflow/test/test_proxy_port.cpp (original)
+++ sandbox/SOC/2007/signals/libs/dataflow/test/test_proxy_port.cpp 2007-10-26 14:53:09 EDT (Fri, 26 Oct 2007)
@@ -48,11 +48,11 @@
     : public df::proxy_port_traits<my_mechanism, df::ports::producer>
 {};
 
-DATAFLOW_PROXY_PORT_CATEGORY(
+DATAFLOW_PROXY_PORT_TRAITS(
     my_non_intrusive_proxy_producer,
     my_non_intrusive_proxy_producer_traits)
 
-DATAFLOW_PROXY_PORT_CATEGORY_ENABLE_IF(
+DATAFLOW_PROXY_PORT_TRAITS_ENABLE_IF(
     T,
     boost::is_same<T BOOST_PP_COMMA() my_non_intrusive_proxy_producer2>,
     my_non_intrusive_proxy_producer_traits)


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk