Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53691 - in sandbox/synchro: boost/synchro/conc libs/synchro/doc libs/synchro/doc/reference libs/synchro/doc/tutorial libs/synchro/example libs/synchro/test
From: vicente.botet_at_[hidden]
Date: 2009-06-06 10:38:45


Author: viboes
Date: 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
New Revision: 53691
URL: http://svn.boost.org/trac/boost/changeset/53691

Log:
Boost.Syncho V0.3.3: extraction of Boost.Rendez-Vous
Removed:
   sandbox/synchro/boost/synchro/conc/
   sandbox/synchro/libs/synchro/doc/reference/concurrent_component.qbk
   sandbox/synchro/libs/synchro/doc/tutorial/rendezvous.qbk
   sandbox/synchro/libs/synchro/example/Accumulator.cpp
   sandbox/synchro/libs/synchro/example/Factorial.cpp
   sandbox/synchro/libs/synchro/example/Histogram.cpp
   sandbox/synchro/libs/synchro/example/HotelReservation.cpp
   sandbox/synchro/libs/synchro/example/Master_Slave.cpp
   sandbox/synchro/libs/synchro/example/QualifiedSingleBuf.cpp
   sandbox/synchro/libs/synchro/example/SingleBuf.cpp
   sandbox/synchro/libs/synchro/example/TrafficLight.cpp
   sandbox/synchro/libs/synchro/test/test.hpp
   sandbox/synchro/libs/synchro/test/unit_test.hpp
Text files modified:
   sandbox/synchro/libs/synchro/doc/history.qbk | 4 +++-
   sandbox/synchro/libs/synchro/doc/index.html | 2 +-
   sandbox/synchro/libs/synchro/doc/introduction.qbk | 4 ++--
   sandbox/synchro/libs/synchro/doc/overview.qbk | 2 --
   sandbox/synchro/libs/synchro/doc/reference.qbk | 1 -
   sandbox/synchro/libs/synchro/doc/references.qbk | 5 -----
   sandbox/synchro/libs/synchro/doc/synchro.qbk | 7 -------
   sandbox/synchro/libs/synchro/doc/tests.qbk | 5 -----
   sandbox/synchro/libs/synchro/doc/tickets.qbk | 9 ---------
   sandbox/synchro/libs/synchro/doc/tutorial.qbk | 1 -
   sandbox/synchro/libs/synchro/doc/users_guide.qbk | 1 -
   sandbox/synchro/libs/synchro/test/Jamfile.v2 | 5 -----
   12 files changed, 6 insertions(+), 40 deletions(-)

Modified: sandbox/synchro/libs/synchro/doc/history.qbk
==============================================================================
--- sandbox/synchro/libs/synchro/doc/history.qbk (original)
+++ sandbox/synchro/libs/synchro/doc/history.qbk 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
@@ -7,6 +7,9 @@
 
 [section:history Appendix A: History]
 
+[section [*Version 0.3.3, May 24, 2009] ['Extraction of Boost.Rendez-Vous]]
+[endsect]
+
 [section [*Version 0.3.2, May 08, 2009] ['Adaptation Boost 1.39 + Extraction of Boost.Conversion]]
 [endsect]
 
@@ -66,7 +69,6 @@
 
 * High-level abstractions for handling more complicated synchronization problems, including
     * `monitor` for guaranteeing exclusive access to an object, and
- * a so-called rendezvous mechanism for handling direct communication between objects `concurrent_components` via `ports` using an accept-synchronize protocol based on the design of the concurrency library in the Beta language.
 
 
 [endsect]

Modified: sandbox/synchro/libs/synchro/doc/index.html
==============================================================================
--- sandbox/synchro/libs/synchro/doc/index.html (original)
+++ sandbox/synchro/libs/synchro/doc/index.html 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
@@ -4,6 +4,6 @@
 </head>
 <body>
 Automatic redirection failed, please go to
-../../doc/html/luid.html
+../../doc/html/synchro.html
 </body>
 </html>

Modified: sandbox/synchro/libs/synchro/doc/introduction.qbk
==============================================================================
--- sandbox/synchro/libs/synchro/doc/introduction.qbk (original)
+++ sandbox/synchro/libs/synchro/doc/introduction.qbk 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
@@ -402,11 +402,11 @@
 
 [endsect]
 
-[section:conc Concurrent components]
+[section:monitors Monitors]
 
 Concurrent components may interact in different ways: they may access the same objects by, for example, executing functions of these objects; or they may communicate directly by executing functions of each other.
 
-Concurrent execution of objects requires a mechanism for synchronizing the access to shared objects, just as direct communication between objects may require synchronization. The basic mechanism for synchronization in Boost.Threads and Boost.Interprocess are the well known mutex and condition_variables. Mutexes and condition variables are, however, only useful for very simple synchronization problems. The Synchro Library therefore introduce high-level abstractions for handling more complicated synchronization problems, including monitor for guaranteeing exclusive access to an object, and a so-called rendezvous mechanism for handling direct communication between objects. All the concurrency abstractions being introduced are defined by means of mutexes an conditions.
+Concurrent execution of objects requires a mechanism for synchronizing the access to shared objects, just as direct communication between objects may require synchronization. The basic mechanism for synchronization in Boost.Threads and Boost.Interprocess are the well known mutex and condition_variables. Mutexes and condition variables are, however, only useful for very simple synchronization problems. The Synchro Library therefore introduce high-level abstractions for handling more complicated synchronization problems, including monitor for guaranteeing exclusive access to an object.
 
 [endsect]
 

Modified: sandbox/synchro/libs/synchro/doc/overview.qbk
==============================================================================
--- sandbox/synchro/libs/synchro/doc/overview.qbk (original)
+++ sandbox/synchro/libs/synchro/doc/overview.qbk 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
@@ -57,8 +57,6 @@
 * High-level abstractions for handling more complicated synchronization problems, including
     * `monitor` for guaranteeing exclusive access to an object.
 
-* A rendezvous mechanism for handling direct communication between objects `concurrent_components` via `ports` using an accept-synchronize protocol based on the design of the concurrency library in the Beta language.
-
 * Language-like Synchronized Block Macros
 
 [/====================================]

Modified: sandbox/synchro/libs/synchro/doc/reference.qbk
==============================================================================
--- sandbox/synchro/libs/synchro/doc/reference.qbk (original)
+++ sandbox/synchro/libs/synchro/doc/reference.qbk 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
@@ -131,7 +131,6 @@
 
 [section High Level]
 [include reference/monitor.qbk]
-[include reference/concurrent_component.qbk]
 [endsect]
 
 

Deleted: sandbox/synchro/libs/synchro/doc/reference/concurrent_component.qbk
==============================================================================
--- sandbox/synchro/libs/synchro/doc/reference/concurrent_component.qbk 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
+++ (empty file)
@@ -1,104 +0,0 @@
-[/
- / Copyright (c) 2008-2009 Vicente J. Botet Escriba
- /
- / 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)
- /]
-
-
-[/==========================================================================================]
-[section:concurrent_component_hpp Header `<boost/synchro/conc/concurrent_component.hpp>`]
-[/==========================================================================================]
-
- namespace boost { namespace synchro {
- class port;
- class object_port;
- template <typename TYPE> class qualified_port;
- class concurrent_component;
- }}
-
-[section Class `port`]
-
- class port {
- public:
- class synchronizer {
- synchronizer(port& that);
- ~synchronizer() {
- };
- port();
- ~port();
- void accept();
- bool accept_until(const boost::posix_time::ptime &abs_time);
- template<typename TimeDuration>
- bool accept_for(TimeDuration const& rel_time);
- };
-
-[endsect]
-
-[section Class `object_port`]
-
- class object_port {
- public:
- class synchronizer {
- synchronizer(object_port& that, const concurrent_component_base* snd);
- ~synchronizer() {
- };
- object_port();
- ~object_port();
- void accept(const void* snd);
- bool accept_until(const void* snd, const boost::posix_time::ptime &abs_time);
- template<typename TimeDuration>
- bool accept_for(const void* snd, TimeDuration const& rel_time);
- };
-
-[endsect]
-
-[section Template Class `qualified_port`]
-
- template <typename TYPE>
- class qualified_port {
- public:
- class synchronizer {
- synchronizer(qualified_port& that, const concurrent_component_base* snd);
- ~synchronizer() {
- };
- object_port();
- ~object_port();
- void accept(const TYPE* snd);
- bool accept_until(const TYPE* snd, const boost::posix_time::ptime &abs_time);
- template<typename TimeDuration>
- bool accept_for(const TYPE* snd, TimeDuration const& rel_time);
- };
-
-[endsect]
-
-[section Class `concurrent_component`]
-
- class concurrent_component
- typedef unspecified port;
- typedef unspecified object_port;
- typedef unspecified qualified_port;
-
- static void accept(port& p);
- static void accept_until(const boost::posix_time::ptime &abs_time, port& p);
- template<typename TimeDuration>
- static bool accept_for(TimeDuration const& rel_time, port& p);
-
- static void accept_all(port& p1, ..., port& pn);
- static void accept_all_until(const boost::posix_time::ptime &abs_time, port& p1, ..., port& pn);
- template<typename TimeDuration>
- static void accept_all_for(TimeDuration const& rel_time, port& p1, ..., port& pn);
-
- static void accept_any(port& p1, ..., port& pn);
- static void accept_any_until(const boost::posix_time::ptime &abs_time, port& p1, ..., port& pn);
- template<typename TimeDuration>
- static void accept_any_for(TimeDuration const& rel_time, port& p1, ..., port& pn);
-
- };
-
-[endsect]
-
-
-
-[endsect]

Modified: sandbox/synchro/libs/synchro/doc/references.qbk
==============================================================================
--- sandbox/synchro/libs/synchro/doc/references.qbk (original)
+++ sandbox/synchro/libs/synchro/doc/references.qbk 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
@@ -56,11 +56,6 @@
     [Douglas C. Schmidt]
 ]
 
-[
- [[@http://www.daimi.au.dk/~beta/Books/index.html
- [*Object-Oriented Programming in the BETA Programming Language ]]]
- [Ole Lehrmann Madsen, Birger Moller-Pedersen, Kristen Nygaard]
-]
   
 ]
 

Modified: sandbox/synchro/libs/synchro/doc/synchro.qbk
==============================================================================
--- sandbox/synchro/libs/synchro/doc/synchro.qbk (original)
+++ sandbox/synchro/libs/synchro/doc/synchro.qbk 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
@@ -93,8 +93,6 @@
 [import ../../../boost/synchro/lockers.hpp]
 [import ../../../boost/synchro/thread_synchronization_family.hpp]
 
-[import ../../../boost/synchro/conc/concurrent_component.hpp]
-
 [import ../../../boost/synchro/lockers/condition_locker.hpp]
 [import ../../../boost/synchro/lockers/externally_locked.hpp]
 [import ../../../boost/synchro/lockers/locking_ptr.hpp]
@@ -105,14 +103,9 @@
 
 [import ../example/BankAccount.cpp]
 [import ../example/EL_BancAccount.cpp]
-[import ../example/Histogram.cpp]
-[import ../example/HotelReservation.cpp]
 [import ../example/IL_BancAccount.cpp]
 [import ../example/IL_Lockable_BancAccount.cpp]
 [import ../example/IL_Rec_Lockable_BancAccount.cpp]
-[import ../example/Master_Slave.cpp]
-[import ../example/SingleBuf.cpp]
-[import ../example/QualifiedSingleBuf.cpp]
 
 
 

Modified: sandbox/synchro/libs/synchro/doc/tests.qbk
==============================================================================
--- sandbox/synchro/libs/synchro/doc/tests.qbk (original)
+++ sandbox/synchro/libs/synchro/doc/tests.qbk 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
@@ -36,11 +36,6 @@
 [table
     [[Name] [Kind] [Description] [Result] [Ticket]]
     [[BankAccount] [run] [ tests] [Pass] [#]]
- [[SingleBuf] [run] [ tests] [Pass] [#]]
- [[Master_Slave] [run] [ tests] [Pass] [#]]
- [[HotelReservation] [run] [ tests] [Fail] [v0.2#2]]
- [[QualifiedSingleBuf] [link] [ tests] [Pass] [#]]
- [[Histogram] [run] [ tests] [Pass] [#]]
     [[IL_BancAccount] [run] [ tests] [Pass] [#]]
     [[IL_Lockable_BancAccount] [run-fail] [ tests] [Pass] [#]]
     [[IL_Rec_Lockable_BancAccount] [run] [ tests] [Pass] [#]]

Modified: sandbox/synchro/libs/synchro/doc/tickets.qbk
==============================================================================
--- sandbox/synchro/libs/synchro/doc/tickets.qbk (original)
+++ sandbox/synchro/libs/synchro/doc/tickets.qbk 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
@@ -29,15 +29,6 @@
     [v0.2]
 ]
 
-[
- [bug]
- [v0.2#2]
- [HotelReservation fails]
- [---]
- [Open]
- [HotelReservation example]
- [v0.2]
-]
 ]
 
 

Modified: sandbox/synchro/libs/synchro/doc/tutorial.qbk
==============================================================================
--- sandbox/synchro/libs/synchro/doc/tutorial.qbk (original)
+++ sandbox/synchro/libs/synchro/doc/tutorial.qbk 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
@@ -20,6 +20,5 @@
 [include tutorial/internal_locking.qbk]
 [include tutorial/volatile_locking_ptr.qbk]
 [include tutorial/external_locking.qbk]
-[include tutorial/rendezvous.qbk]
 
 [endsect]

Deleted: sandbox/synchro/libs/synchro/doc/tutorial/rendezvous.qbk
==============================================================================
--- sandbox/synchro/libs/synchro/doc/tutorial/rendezvous.qbk 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
+++ (empty file)
@@ -1,145 +0,0 @@
-[/
- / Copyright (c) 2008 Vicente J. Botet Escriba
- /
- / 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)
- /]
-
-[section Concurrent components]
-[note This tutorial is an adaptation of chapter Concurrency of the Object-Oriented Programming in the BETA Programming Language to the Boost library.]
-[section Direct communication between components]
-
-In the previous section we have described a mechanism for concurrent components to communicate through shared objects. In many cases it appears more natural for concurrent components to communicate directly instead of using shared objects. Consider the following example:
-
-[synchronized_communication_between_components_schema]
-
-Here the concurrent components `S` and `R` call operations on each other. The state of `S` may, however, not be meaningful when `R` executes `m`, and vice versa. In the following sections we will introduce abstractions for making it possible to synchronize such communication.
-
-[section Synchronized communication between components]
-
-In this section we will introduce the notion of synchronized execution of objects. A component `S` may request execution of a member function of a component `R`. The component `R` must accept that the request can be fulfilled. Synchronized communication is described in a generic class concurrent_component. A `concurrent_component` defines the notion of a `port` for controlling the communication. A `port` has a nested `synchronizer` class for defining operations controlled by the `port`; it also has an accept operation for signaling that an operation associated with the `port` can be executed. The `concurrent_component` has the following structure:
-
-[port]
-
-The following object illustrates two communicating `concurrent_component`s:
-
-[synchronized_communication_between_components]
-
-The concurrent_component `S` may execute a request, which is a normal remote procedure call:
-
-```
- e2 = r_.m(e1);
-```
-
-Since `m` is a synchronized port operation, the execution of M has to be accepted
-by R before it is executed. For M to be accepted, R must execute an accept, which has the following form:
-
-```
- port::accept(p);
-```
-
-The communication is carried out when `S` is executing `r_.m` and `R` is executing
-`port::accept(p)`. Both `S` and `R` are blocked until the communication takes place. A
-communication has the effect that `S` and `R` together execute the evaluation: `e2 = r_.m(e1);`
-
-This takes place as follows:
-
-# When S executes `e2 = r_.m(e1)`, `S` is now ready to execute the internals of the `R::m`.
-# When `R` executes `port::accept(p)`, `R` has signaled that the internals of a function protected with `port::synchronizer `_(p)`; may be executed. `R` will wait until such an execution has taken place.
-# When both `R` and `S` are ready, the internals of `R::m` can be executed.
-# When the internals of `R::m` has been executed, `R` will continue execution. In addition, a possible return of `R::m` is assigned to `e2`.
-
-The object `S` executing `r_.m()` is called the sender, and the object `R` having `m` as an operation is called the receiver.
-
-In the following example, two systems `Prod` and `Cons` communicate via a single element buffer represented by a `SingleBuf` concurrent_component. The `SingleBuf` concurrent_component alternates between accepting a `Push` and a `Pull`:
-
-[SingleBuf]
-
-[endsect]
-[section Ports controlling several operations]
-
-It is possible to associate more than one operation with a port.
-
-The `Master`-concurrent_component transmits a sequence of values to the two `Slave`-systems, and each Slave-concurrent_component computes the sum of the values being received. Each value is received and accumulated by a synchronous execution of `Add`. A Slave object can be used according to the following protocol:
-
-# The `Clear` operation must be used to initiate a new sequence of summations. A `Clear` thus terminates any ongoing summation.
-# The `Add` operation accumulates a new value.
-# The `Result` operation returns the current sum. In the example, positive numbers are transmitted to `Slave1` and negative numbers are transmitted to `Slave2`.
-
-[Master_Slave_Slave]
-
-[Master_Slave_Master]
-
-
-[endsect]
-
-[section Restricted acceptance]
-
-An accept operation on a port signals that any object is allowed to execute an operation associated with the port. Sometimes it is desirable to restrict the possible objects that are allowed to execute a port operation. The restriction may specify that one specific object is allowed to execute a port operation, or it may specify that instances of a specific class are allowed to execute a port operation. These two types of restrictions are described in the following two sections.
-
-[*Object restriction]
-
-It is possible to restrict the sender of an operation by declaring the port as an instance of the `object_port` class. The `accept` operation of an `object_port` has a parameter which is a reference to the object that is allowed to execute a port operation. As C++ do not allows to recover the sender of an operation we need pass it as parameter.
-
-The syntax for this is:
-
- T S; //some component reference
- object_port request_;
- void Close(const concurrent_component_base* snd) {
- object_port::synchronizer _(request_, snd);
- // ...
- }
- //...
- object_port::accept(request_, sender_); // sender_ has been stored previously
-
-
-The example describes an abstract pattern for handling reservations of some kind. The reservations are supposed to be stored in some register. The actual way this is done is supposed to be described in sub-classes of ReservationHandler. At most, one person at a time is allowed to make reservations. An agent making a reservation must perform the following steps:
-
-
-# The register must be locked by executing the Lock operation.
-# The agent may then perform one or more reservations using Reserve.
-# The agent terminates the reservation session by executing Close.
-
-The example includes a sketch of a handler for hotel reservations. The concurrent_component P describes a scenario of an agent making two hotel reservations.
-
-[ReservationHandler]
-
-[HotelResHandler]
-
-[HotelResHandler_main]
-
-[*Qualified restriction]
-
-The object_port described above makes it possible to ensure that only one specific concurrent_component may execute a port operation. It is often desirable to specify that a port operation may be executed by a restricted set of `concurrent_component`s. By using a port instantiated from `qualified_port`, it is possible to define port operations that may be executed by objects of a given class. The syntax for
-this is:
-
-
-Port operations associated with P may now be executed by an object which is an instance of T or inherits from T.
-
-The following example illustrates the use of a qualified port. The single buffer example is modified such that Push can only be executed by Producer objects and Pull can only be executed by Consumer objects.
-
-[QualifiedSingleBuf]
-
-[endsect]
-
-[endsect]
-
-[section Compound concurrent components]
-
-[section Indirect communication between internal concurrent components]
-
-Composition is a fundamental means for organizing objects. We have several examples of defining an object as compositions of other objects using part objects, references and block structure. We have also seen how the action part of an object may be composed of other objects. In this section we shall show how to construct compound systems that are concurrent_component objects consisting of several internal multiple action sequences.
-
-In Boost.Synchro the actions to be performed by a concurrent_component may be distributed among several internal systems. The internal systems may be more or less independent, and they may access common data (items in an enclosing concurrent_component), communicate with each other, communicate with external systems or control communication between external systems, and the enclosing concurrent_component.
-
-In the following, examples of such compound systems are described. For compound systems consisting of several internal concurrent systems, we are often interested in describing that execution of the outermost concurrent_component cannot terminate before execution of all inner systems have terminated. The outermost concurrent_component may have to do some initialization before executing the inner concurrent_component, and it may have to do some finalization (clean-up) when they have finished execution. The concurrent_component class has a concurrent_execution nested class that can be used for this purpose. concurrent_component can be used in the following way:
-
- concurrent_execution<S1,S2, S3)> conc(s1,s2, s3);
- conc();
- conc.join();
-
-[Histogram]
-
-[endsect]
-[endsect]
-[endsect]

Modified: sandbox/synchro/libs/synchro/doc/users_guide.qbk
==============================================================================
--- sandbox/synchro/libs/synchro/doc/users_guide.qbk (original)
+++ sandbox/synchro/libs/synchro/doc/users_guide.qbk 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
@@ -28,7 +28,6 @@
 [[locker] [.]]
 [[lifetime] [.]]
 [[scope] [.]]
-[[scope] [.]]
 ]
 
 [endsect]

Deleted: sandbox/synchro/libs/synchro/example/Accumulator.cpp
==============================================================================
--- sandbox/synchro/libs/synchro/example/Accumulator.cpp 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
+++ (empty file)
@@ -1,61 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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)
-//
-// See http://www.boost.org/libs/synchro for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include <boost/coroutine/coroutine.hpp>
-
-namespace coro=boost::coroutines;
-
-template <class Derived, typename Signature,
-typename ContextImpl = detail::default_context_impl>
-class coroutine_obj;
-
-template <class Derived, typename Res, typename Param1, typename ContextImpl>
-class coroutine_obj<Derived, Res(Param1), ContextImpl> {
- typedef coro::coroutine<Res(Param1), ContextImpl> coroutine_type;
- coroutine_type couroutine_;
-public:
- coroutine_obj() : couroutine_(Derived::body_) {}
- Res operator()(Param1 val) {
- return couroutine_(val);
- }
-};
-template <class Derived, typename ContextImpl>
-class coroutine_obj<Derived, void(), ContextImpl> {
- typedef coro::coroutine<void()> coroutine_type;
- coroutine_type couroutine_;
-public:
- coroutine_obj() : couroutine_(Derived::body_) {}
- void operator()() {
- couroutine_();
- }
-};
-
-//[Acumulator
-class Acumulator : public coroutine_obj<Acumulator, int(int)> {
- typedef coroutine_obj<Acumulator, int(int)> super_type;
- friend class super_type;
- static int body(coroutine_type::self& this_coroutine, int val) {
- while(true) {
- val += this_coroutine.yield(val);
- }
- }
-};
-
-//]
-
-int main()
-{
- Acumulator accumulator;
- for(int i = 0; i < 1000; ++i)
- std::cout << accumulator(i);
- return 0;
-}
-
-

Deleted: sandbox/synchro/libs/synchro/example/Factorial.cpp
==============================================================================
--- sandbox/synchro/libs/synchro/example/Factorial.cpp 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
+++ (empty file)
@@ -1,63 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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)
-//
-// See http://www.boost.org/libs/synchro for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include <boost/synchro/alt/alternating_component.hpp>
-
-using namespace boost::alt;
-using namespace boost;
-
-//[TrafficLight
-class factorial {
- unsigned value[100];
- unsigned top_
- unsigned operator()(unsigned n) {
- T[0]=top_=0;
- for(;;) {
- if (top_<n) {
- for (i=top_+1; i<=n; ++i) {
- value_[i]=value_[i-1]*i
- }
- top_ = n;
- }
- ++n;
- alternating_component::yield(value_[n-1]);
- }
- }
-};
-
-class Controller {
- alternating_component<TrafficLight> north, south;
-public:
- Controller( alternating_component<TrafficLight> north, south)
- void operator()() {
- north.resume(); // north.state_==red
- south.resume();
- south.resume(); // south.state_==green
- for(;;) {
- // wait some time
- sleep(2);
- // switch the states
- south.resume();
- north.resume();
- }
- }
-};
-
-//]
-
-int main()
-{
- alternating_component<TrafficLight> north, south;
- alternating_component<Controller> controler(north, south); // Declaration of a singular component
- controler.start();
- return 0;
-}
-
-

Deleted: sandbox/synchro/libs/synchro/example/Histogram.cpp
==============================================================================
--- sandbox/synchro/libs/synchro/example/Histogram.cpp 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
+++ (empty file)
@@ -1,148 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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)
-//
-// See http://www.boost.org/libs/synchro for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include <boost/synchro/conc/concurrent_component.hpp>
-#include <boost/synchro/monitor.hpp>
-#include <boost/synchro/thread/mutex.hpp>
-#include <boost/thread.hpp>
-#include <boost/ref.hpp>
-#if 0
-#include <boost/synchro/conc/conc_tuple.hpp>
-#else
-#include <boost/async/algorithm.hpp>
-#include <boost/async/typeof/threader.hpp>
-#endif
-
-namespace {
- volatile int Run = 1;
-}
-
-using namespace boost::synchro;
-using namespace boost;
-
-
-//[Histogram
-class Histogram : boost::synchro::concurrent_component {
-
- class HistogramData : public exclusive_monitor<> {
- unsigned R[100];
- public:
- HistogramData() {
- for (int i = 0; i<100; i++) R[i] = 0;
- }
- void Add(unsigned i) {
- synchronizer _(*this->mutex());
- R[i]+=1;
- }
- void Sub(unsigned i) {
- synchronizer _(*this->mutex());
- R[i]=(R[i]>0)?R[i]-1:0;
- }
- unsigned Get(unsigned i) {
- synchronizer _(*this->mutex());
- return R[i];
- }
- };
- class Display : boost::synchro::concurrent_component {
- HistogramData& histogramData_;
- public:
- typedef void result_type;
- Display(HistogramData& histogramData) : histogramData_(histogramData) {}
- void operator()()
- {
- for (int i=10;i>0;--i) {
- boost::this_thread::sleep(boost::posix_time::seconds(1));
- for (unsigned i =0; i<100; ++i) {
- std::cout << "==(" << i << ", "
- << histogramData_.Get(i) << ")"
- << std::endl;
- }
- }
- }
- };
- class Update : boost::synchro::concurrent_component {
- Histogram::port& request_;
- public:
- typedef void result_type;
- Update(Histogram::port& req) : request_(req) {}
- void operator()()
- {
- for (int i=10;i>0;--i) {
- accept(request_);
- }
- }
- };
- port request_;
- HistogramData histogramData_;
-// friend class Update;
- Display disp_;
- Update updater_;
-public:
- typedef void result_type;
- Histogram()
- : disp_(histogramData_)
- , updater_(request_)
- {}
- void NewValue(int V) {
- port::synchronizer _(request_);
- if (V>0) histogramData_.Add(V);
- else histogramData_.Sub(-V);
- }
- void operator()() {
- #if 0
- conc_tuple<Display,Update> conc_(disp_, updater_);
- conc_();
- conc_.join();
- #else
- boost::async::shared_threader ae;
- BOOST_AUTO(conc_, boost::async::fork_all(ae, boost::bind(boost::ref(disp_)), boost::bind(boost::ref(updater_))));
- boost::async::join_all(conc_);
- #endif
-
- }
-};
-//]
-class S : boost::synchro::concurrent_component {
- Histogram& histogram_;
-public:
- typedef void result_type;
- S(Histogram& histogram) : histogram_(histogram) {}
- void operator()()
- {
- for (int i=10;i>0;--i) {
- // TODO replace by random
- boost::this_thread::sleep(boost::posix_time::seconds(1));
- histogram_.NewValue(i);
-
- }
- }
-};
-
-int main()
-{
- Histogram histo;
- S snd(histo);
- #if 0
- conc_tuple<Histogram, S> conc(histo, snd);
- conc();
- boost::this_thread::sleep(boost::posix_time::seconds(10));
-
- conc.join();
- #else
- boost::async::shared_threader ae;
- BOOST_AUTO(conc, boost::async::fork_all(ae, boost::bind(boost::ref(histo)), boost::bind(boost::ref(snd))));
- boost::this_thread::sleep(boost::posix_time::seconds(10));
- boost::async::join_all(conc);
- #endif
-
- return 0;
-}
-
-

Deleted: sandbox/synchro/libs/synchro/example/HotelReservation.cpp
==============================================================================
--- sandbox/synchro/libs/synchro/example/HotelReservation.cpp 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
+++ (empty file)
@@ -1,220 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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)
-//
-// See http://www.boost.org/libs/synchro for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include <boost/synchro/conc/concurrent_component.hpp>
-#include <boost/synchro/thread/mutex.hpp>
-#include <boost/thread.hpp>
-#include <boost/ref.hpp>
-#include <string>
-
-#if 0
-#include <boost/synchro/conc/conc_tuple.hpp>
-#endif
-
-#include <boost/interthreads/algorithm.hpp>
-#include <boost/interthreads/typeof/threader.hpp>
-
-#include <boost/test/unit_test.hpp>
-boost::mutex MTX;
-
-#define ABOOST_TEST_MESSAGE(MSG) { \
-/*boost::lock_guard<boost::mutex> g(MTX);*/ \
-std::cout << __LINE__ << MSG << std::endl; \
-}
-
-#define ABOOST_TEST_CHECKPOINT(MSG) { \
- /*boost::lock_guard<boost::mutex> g(MTX); */\
- std::cout << __LINE__ << MSG << std::endl; \
-}
-
-using namespace boost::synchro;
-using namespace boost;
-
-//namespace {
-// volatile int Run = 1;
-//}
-
-//[ReservationHandler
-class ReservationHandler : public boost::synchro::concurrent_component
-{
-protected:
- port lock_or_interrupt_;
- object_port request_;
- const concurrent_component_base* sender_;
- bool closed_;
- bool interrupted_;
-public:
- typedef void result_type;
- ReservationHandler() : sender_(0), closed_(true), interrupted_(false) {}
- void Lock(const concurrent_component_base* snd) {
- ABOOST_TEST_CHECKPOINT("Lock")
- port::synchronizer _(lock_or_interrupt_);
- ABOOST_TEST_CHECKPOINT("Locked")
- sender_ = snd;
- closed_ =false;
- }
- void Interrupt() {
- ABOOST_TEST_CHECKPOINT("Interrupt")
- port::synchronizer _(lock_or_interrupt_);
- interrupted_ =true;
- }
-// void Reserve(const concurrent_component_base& snd) {
-// object_port::synchronizer _(request_, snd);
-// Reserv();
-// }
-// virtual void Reserve()=0;
-
- void Close(const concurrent_component_base* snd) {
- ABOOST_TEST_CHECKPOINT("Close")
- object_port::synchronizer _(request_, snd);
- closed_ =true;
- sender_ = 0;
- DoClose();
- }
- virtual void DoClose() {};
- void operator()() {
- while (!interrupted_) {
- accept(lock_or_interrupt_);
- if (interrupted_) break;
- while (!closed_) {
- accept(request_, sender_);
- }
- }
- }
-// ReservationHandler()
-// : closed_(false)
-// {}
- virtual ~ReservationHandler() {};
-};
-//]
-
-//[HotelResHandler
-class HotelResHandler : public ReservationHandler
-{
- unsigned roomNo;
-public:
- unsigned Reserve(const concurrent_component_base* snd
- , std::string guestName
- , unsigned noOfPersons) {
- ABOOST_TEST_CHECKPOINT("Reserve")
- object_port::synchronizer _(request_, snd);
- // ...
- ++roomNo;
- ABOOST_TEST_CHECKPOINT(roomNo<<":"<<guestName<<" #"<<noOfPersons)
- return roomNo;
- }
- virtual void DoClose(){};
- virtual ~HotelResHandler() {};
-};
-//]
-
-//[HotelResHandler_P
-class P : public boost::synchro::concurrent_component {
-public:
- typedef void result_type;
- HotelResHandler& hrh_;
- P(HotelResHandler& hrh):hrh_(hrh) {}
- void operator()() {
- ABOOST_TEST_MESSAGE("P Lock")
- hrh_.Lock(this);
- ABOOST_TEST_MESSAGE("P Reserve")
- unsigned rno1 = hrh_.Reserve(this, std::string("Peter Olsen"),4);
- ABOOST_TEST_CHECKPOINT(rno1)
- ABOOST_TEST_MESSAGE("P Reserve")
- unsigned rno2 = hrh_.Reserve(this, std::string("Anne Nielsen"),2);
- ABOOST_TEST_CHECKPOINT(rno2)
- hrh_.Close(this);
- ABOOST_TEST_MESSAGE("P Close")
- }
-};
-//]
-
-//[HotelResHandler_Q
-class Q : public boost::synchro::concurrent_component {
-public:
- typedef void result_type;
- HotelResHandler& hrh_;
- Q(HotelResHandler& hrh):hrh_(hrh) {}
- void operator()() {
- ABOOST_TEST_MESSAGE("Q Lock")
- hrh_.Lock(this);
- ABOOST_TEST_MESSAGE("Q Reserve")
- unsigned rno1 = hrh_.Reserve(this, std::string("Carmen"),5);
- ABOOST_TEST_CHECKPOINT(rno1)
- ABOOST_TEST_MESSAGE("Q Reserve")
- unsigned rno2 = hrh_.Reserve(this, std::string("Javier"),1);
- ABOOST_TEST_CHECKPOINT(rno2)
- hrh_.Close(this);
- ABOOST_TEST_MESSAGE("Q Close")
- }
-};
-//]
-
-class R : public boost::synchro::concurrent_component {
-public:
- typedef void result_type;
- HotelResHandler& hrh_;
- R(HotelResHandler& hrh):hrh_(hrh) {}
- void operator()() {
- try {
- ABOOST_TEST_MESSAGE("R Reserve")
- unsigned rno1 = hrh_.Reserve(this, std::string("Carmen"),5);
- }catch (bad_sender& exp) {
- ABOOST_TEST_MESSAGE("You need to Lock first")
- }catch (...) {
- std::cout << "... You need to Lock first" << std::endl;
- }
- }
-};
-//]
-
-//[HotelResHandler_main
-int main() {
- HotelResHandler hrh;
- P p(hrh);
- Q q(hrh);
- R r(hrh);
-#if 1
- boost::interthreads::shared_threader ae;
- BOOST_AUTO(hrh_act, boost::interthreads::fork(ae, boost::bind(boost::ref(hrh))));
- BOOST_AUTO(conc, boost::interthreads::fork_all(ae, boost::bind(boost::ref(p)), boost::bind(boost::ref(q)), boost::bind(boost::ref(r))));
- boost::interthreads::join_all(conc);
- hrh.Interrupt();
- boost::interthreads::join(hrh_act);
-#else
- conc_tuple<HotelResHandler, P, Q, R> conc(hrh, p, q, r);
- conc();
-
- boost::this_thread::sleep(boost::posix_time::seconds(4));
-
- hrh.Interrupt();
- conc.join();
-
-#if 0
- boost::thread thread1(boost::ref(hrh));
- boost::thread thread2(boost::ref(p));
- boost::thread thread3(boost::ref(q));
- boost::thread thread4(boost::ref(r));
-
- boost::this_thread::sleep(boost::posix_time::seconds(1));
- hrh.Interrupt();
-
- thread2.join();
- thread3.join();
- thread4.join();
- thread1.join();
-
-#endif
-
-#endif
- return 0;
-}
-//]
-

Deleted: sandbox/synchro/libs/synchro/example/Master_Slave.cpp
==============================================================================
--- sandbox/synchro/libs/synchro/example/Master_Slave.cpp 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
+++ (empty file)
@@ -1,116 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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)
-//
-// See http://www.boost.org/libs/synchro for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include <boost/synchro/conc/concurrent_component.hpp>
-#include <boost/synchro/thread/mutex.hpp>
-#include <boost/thread.hpp>
-#include <boost/ref.hpp>
-#include <boost/synchro/conc/conc_tuple.hpp>
-
-using namespace boost::synchro;
-using namespace boost;
-
-
-
-namespace {
-}
-
-//[Master_Slave_Slave
-class Slave : boost::synchro::concurrent_component
-{
- port receive_;
- unsigned sum_;
- bool End;
-public:
- Slave() : End(false) {}
- void Clear() {
-// std::cout << "Clear()" << std::endl;
- port::synchronizer _(receive_);
- sum_ = 0;
- }
- void Add(unsigned v) {
-// std::cout << "Add(" << v << ")" << std::endl;
- port::synchronizer _(receive_);
- sum_+=v;
- }
- unsigned Result() {
- port::synchronizer _(receive_);
-// std::cout << sum_ << "=Result()" << std::endl;
- return sum_;
- }
- void Interrupt() {
-// std::cout << "Interrupt()" << std::endl;
- port::synchronizer _(receive_);
- End=true;
- }
- void operator()() {
- while (!End) {
-// std::cout << "accept()" << std::endl;
- accept(receive_);
- }
- }
-};
-//]
-//[Master_Slave_Master
-struct Master : boost::synchro::concurrent_component {
- Slave& Slave1_;
- Slave& Slave2_;
-
- int V[100];
- Master(Slave& slave1, Slave& slave2)
- : Slave1_(slave1)
- , Slave2_(slave2)
- {}
- void operator()()
- {
- for (int i=0; i<100; i++) {
- V[i]=i;
- }
-// std::cout << "before clear" << std::endl;
- Slave1_.Clear();
- Slave2_.Clear();
-// std::cout << "cleared" << std::endl;
-
- for (int i=0; i<100; i++) {
- if ((V[i]%2) > 0) Slave1_.Add(V[i]);
- else Slave2_.Add(V[i]);
- }
- std::cout << Slave1_.Result() << std::endl;
- std::cout << Slave2_.Result() << std::endl;
- Slave1_.Interrupt();
- Slave2_.Interrupt();
- }
-};
-//]
-
-int main()
-{
-
- std::cout << "BEGIN" << std::endl;
- Slave slave1;
- Slave slave2;
- Master master(slave1, slave2);
-#if 1
- conc_tuple<Slave, Slave, Master> conc(slave1, slave2, master);
- conc();
- conc.join();
-#else
- boost::thread thread1(boost::ref(slave1));
- boost::thread thread2(boost::ref(slave2));
- boost::thread thread3(boost::ref(master));
- std::cout << "wait" << std::endl;
-
- thread1.join();
- thread2.join();
- thread3.join();
-#endif
- return 0;
-}
-

Deleted: sandbox/synchro/libs/synchro/example/QualifiedSingleBuf.cpp
==============================================================================
--- sandbox/synchro/libs/synchro/example/QualifiedSingleBuf.cpp 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
+++ (empty file)
@@ -1,92 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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)
-//
-// See http://www.boost.org/libs/synchro for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include <boost/synchro/conc/concurrent_component.hpp>
-#include <boost/synchro/thread/mutex.hpp>
-#include <boost/thread.hpp>
-#include <boost/ref.hpp>
-#include <boost/synchro/conc/conc_tuple.hpp>
-
-namespace {
- volatile int Run = 1;
-}
-
-using namespace boost::synchro;
-using namespace boost;
-
-struct Producer;
-struct Consumer;
-
-//[QualifiedSingleBuf
-class SingleBuf : boost::synchro::concurrent_component {
- qualified_port<Producer> PutPort_;
- qualified_port<Consumer> GetPort_;
-// const concurrent_component_base* sender_;
- char bufCh_;
-public:
- void Put(const Producer* snd, char ch) {
- qualified_port<Producer>::synchronizer _(PutPort_, snd);
- bufCh_ = ch;
- }
- char Get(const Consumer* snd) {
- qualified_port<Consumer>::synchronizer _(GetPort_, snd);
- return bufCh_;
- }
- void operator()() {
- while (Run) {
- accept(PutPort_);
- if (!Run) break;
- accept(GetPort_);
- }
- }
-};
-//]
-struct Producer : boost::synchro::concurrent_component {
- SingleBuf& buf_;
- Producer(SingleBuf& buf) : buf_(buf) {}
- void operator()()
- {
- char ch=32;
- while (Run) {
- ch+=1;
- if (ch > 65) ch = 32;
- buf_.Put(this, ch);
- }
- }
-};
-struct Consumer : boost::synchro::concurrent_component {
- SingleBuf& buf_;
- Consumer(SingleBuf& buf) : buf_(buf) {}
- void operator()() {
- while (Run) {
- char ch = buf_.Get(this);
- std::cout << ch << std::endl;
- }
- }
-};
-
-int main()
-{
- std::cout << "press <enter> to end the program" << std::endl;
-
- SingleBuf buf;
- Producer prod(buf);
- Consumer cons(buf);
- conc_tuple<SingleBuf, Producer, Consumer> conc(buf, prod, cons);
- conc();
-
- std::cin.get();
- Run = 0;
- conc.join();
-
- return 0;
-}
-
-

Deleted: sandbox/synchro/libs/synchro/example/SingleBuf.cpp
==============================================================================
--- sandbox/synchro/libs/synchro/example/SingleBuf.cpp 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
+++ (empty file)
@@ -1,106 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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)
-//
-// See http://www.boost.org/libs/synchro for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include <boost/synchro/conc/concurrent_component.hpp>
-#include <boost/synchro/thread/mutex.hpp>
-#include <boost/thread.hpp>
-#include <boost/ref.hpp>
-#include <boost/synchro/conc/conc_tuple.hpp>
-
-namespace {
- volatile int Run = 1;
-}
-
-using namespace boost::synchro;
-using namespace boost;
-
-//[SingleBuf
-class SingleBuf : boost::synchro::concurrent_component {
- port PutPort_,GetPort_;
- char bufCh_;
- bool End;
-public:
- SingleBuf() : End(false) {}
- void Put(char ch) {
- port::synchronizer _(PutPort_);
-// std::cout << "void Put("<<ch<<")" << std::endl;
- bufCh_ = ch;
- }
- char Get() {
- port::synchronizer _(GetPort_);
-// std::cout << bufCh_<<"=Get()" << std::endl;
- return bufCh_;
- }
- void Interrupt() {
- port::synchronizer _(PutPort_);
-// std::cout << "Interrupt()" << std::endl;
- End=true;
- }
- void operator()() {
- while (!End) {
-// std::cout << "port::accept(PutPort_)"<<std::endl;
- accept(PutPort_);
- if (End) break;
-// std::cout << "port::accept(GetPort_)"<<std::endl;
- accept(GetPort_);
- }
- }
-};
-struct Producer : boost::synchro::concurrent_component{
- SingleBuf& buf_;
- Producer(SingleBuf& buf) : buf_(buf) {}
- void operator()()
- {
- buf_.Put('h');
- buf_.Put('e');
- buf_.Put('l');
- buf_.Put('l');
- buf_.Put('o');
- buf_.Put(' ');
- buf_.Put('w');
- buf_.Put('o');
- buf_.Put('r');
- buf_.Put('l');
- buf_.Put('d');
- buf_.Put('!');
- buf_.Put('\n');
- }
-};
-struct Consumer : boost::synchro::concurrent_component{
- SingleBuf& buf_;
- Consumer(SingleBuf& buf) : buf_(buf) {}
- void operator()() {
- for (;;) {
-// std::cout << "wait " << std::endl;
- char ch = buf_.Get();
- std::cout << ch;
- if (ch=='\n') break;
- }
- }
-};
-//]
-
-int main()
-{
-// std::cout << "press <enter> to end the program" << std::endl;
-
- SingleBuf buf;
- Producer prod(buf);
- Consumer cons(buf);
- conc_tuple<SingleBuf, Producer, Consumer> conc(buf, prod, cons);
- conc();
-
- boost::this_thread::sleep(boost::posix_time::seconds(3));
- buf.Interrupt();
-
- conc.join();
- return 0;
-}
-

Deleted: sandbox/synchro/libs/synchro/example/TrafficLight.cpp
==============================================================================
--- sandbox/synchro/libs/synchro/example/TrafficLight.cpp 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
+++ (empty file)
@@ -1,132 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Vicente J. Botet Escriba 2008-2009. 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)
-//
-// See http://www.boost.org/libs/synchro for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include <boost/synchro/alt/alternating_component.hpp>
-
-using namespace boost::alt;
-using namespace boost;
-
-namespace color {
- enum type {red, green};
-}
-
-//[TrafficLight
-# if 0
-class TrafficLight : public coroutine_obj<TrafficLight, void(void)> {
- typedef coroutine_obj<TrafficLight, void(void)> super_type;
- friend class super_type;
- static void body(coroutine_type::self& this_coroutine) {
- for(;;) {
- state_ = color::red;
- this_coroutine.yield();
- state_ = color::green;
- this_coroutine.yield();
- }
- }
- color::type state_;
-public:
- TrafficLight() : state_(color::red) {}
-};
-
-class Controller {
- TrafficLight north_, south_;
- operator() body() {
- north_(); // north.state_==red
- south_();
- south_(); // south.state_==green
- for(;;) {
- // wait some time
- sleep(2);
- // switch the states
- south_();
- north_();
- }
- }
-public:
- Controller(TrafficLight& north, TrafficLight& south);
-};
-#endif
-typedef coro::coroutine<void()> TrafficLight;
-
-void TrafficLightBody(TrafficLight::self& this_coroutine) {
- color::type state_=color::red;
- for(;;) {
- state_ = color::red;
- this_coroutine.yield();
- state_ = color::green;
- this_coroutine.yield();
- }
-}
-
-void Controller(TrafficLight north_, TrafficLight south_) {
- north_(); // north.state_==red
- south_();
- south_(); // south.state_==green
- for(;;) {
- // wait some time
- sleep(2);
- // switch the states
- south_();
- north_();
- }
-}
-
-int main()
-{
- TrafficLight north(TrafficLightBody);
- TrafficLight south(TrafficLightBody);
- Controller controler(north, south); // Declaration of a singular component
- return 0;
-}
-
-
-class TrafficLight {
- color::type state_;
-public:
- TrafficLight() : state_(color::red) {}
- void operator()() {
- for(;;) {
- state_ = color::red;
- alternating_component::suspend();
- state_ = color::green;
- alternating_component::suspend();
- }
- }
-};
-
-class Controller {
- alternating_component<TrafficLight> north, south;
-public:
- Controller( alternating_component<TrafficLight> north, alternating_component<TrafficLight> south)
- void operator()() {
- north.resume(); // north.state_==red
- south.resume();
- south.resume(); // south.state_==green
- for(;;) {
- // wait some time
- sleep(2);
- // switch the states
- south.resume();
- north.resume();
- }
- }
-};
-
-//]
-
-int main()
-{
- alternating_component<TrafficLight> north, south;
- alternating_component<Controller> controler(north, south); // Declaration of a singular component
- controler.start();
- return 0;
-}
-
-

Modified: sandbox/synchro/libs/synchro/test/Jamfile.v2
==============================================================================
--- sandbox/synchro/libs/synchro/test/Jamfile.v2 (original)
+++ sandbox/synchro/libs/synchro/test/Jamfile.v2 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
@@ -59,11 +59,6 @@
     
 test-suite "examples" :
     [ run ../example/BankAccount.cpp ]
- [ run ../example/SingleBuf.cpp ]
- [ run ../example/Master_Slave.cpp ]
-## [ run ../example/HotelReservation.cpp ]
- [ link ../example/QualifiedSingleBuf.cpp ]
- [ run ../example/Histogram.cpp ]
     [ run ../example/IL_BancAccount.cpp ]
     [ run-fail ../example/IL_Lockable_BancAccount.cpp ]
     [ run ../example/IL_Rec_Lockable_BancAccount.cpp ]

Deleted: sandbox/synchro/libs/synchro/test/test.hpp
==============================================================================
--- sandbox/synchro/libs/synchro/test/test.hpp 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
+++ (empty file)
@@ -1,192 +0,0 @@
-/* Copyright 2008-2009 Vicente J. Botet Escriba
- * 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)
- *
- * See http://www.boost.org/libs/luid for library home page.
- */
-
-#ifndef BOOST_LUID_TEST_TEST_HPP_
-#define BOOST_LUID_TEST_TEST_HPP_
-
-#include <boost/test/unit_test.hpp>
-#include <boost/luid/generator.hpp>
-#include <set>
-
-using namespace boost;
-using namespace boost::mpl;
-namespace bip =boost::interprocess;
-namespace bdsl =boost::dsl;
-
-namespace bluid = boost::luid;
-
-template <typename G>
-void test_inmediate(G& g) {
- typename G::numeric_type id1= g.make();
- g.release(id1);
- typename G::numeric_type id2= g.make();
- BOOST_CHECK(id1==id2);
- g.clear();
-}
-
-template <typename G>
-void test_fifo(G& g) {
- typename G::numeric_type id1= g.make();
- typename G::numeric_type id2= g.make();
- typename G::numeric_type id3= g.make();
- g.release(id2);
- g.release(id3);
- g.release(id1);
- typename G::numeric_type id4= g.make();
- BOOST_CHECK(id4==id2);
- typename G::numeric_type id5= g.make();
- BOOST_CHECK(id5==id3);
- typename G::numeric_type id6= g.make();
- BOOST_CHECK(id6==id1);
- g.clear();
-}
-
-template <typename G>
-void test_resize(G& g, unsigned int d, unsigned int u) {
- typename G::numeric_type i;
- for (i =g.lower_bound(); i<d; ++i) {
- BOOST_CHECK(g.make()!=g.error());
- }
- std::cout << "test_resize # " << d << std::endl;
- g.set_upper_bound(u);
- std::cout << "test_resize # " << g.upper_bound() << std::endl;
- for (;i<g.upper_bound(); ++i) {
- BOOST_CHECK(g.make()!=g.error());
- }
- std::cout << "test_resize # " << u << std::endl;
-// BOOST_CHECK(g.make()==g.error());
- g.clear();
-}
-
-template <typename G, typename D>
-void test_delay(G& g, D d) {
-// std::cout << "T." <<++i<< " test_delay " << std::endl;
- typename G::numeric_type id1= g.make();
- g.release(id1);
-// std::cout << "test_delay # " << g.count() << std::endl;
- typename G::numeric_type id2= g.make();
- BOOST_CHECK(id1!=id2);
-// thread::sleep(boost::posix_time::second_clock::local_time()+posix_time::time_duration(0,0,d,0));
- sleep(d);
- typename G::numeric_type id3= g.make();
- BOOST_CHECK(id1==id3);
-// std::cout << "test_delay # " << g.count() << std::endl;
- g.clear();
-// g.release(id2);
-// g.release(id3);
-}
-
-template <typename G>
-void test_unique(G& g) {
-// std::cout << "T." <<++i<< " test_unique " << std::endl;
-
-// typedef std::set<> used_type;
- typedef std::set<typename G::numeric_type> used_type;
- used_type used;
- typename G::numeric_type id;
- for (typename G::numeric_type i =g.lower_bound(); i<g.upper_bound(); ++i) {
- id=g.make();
- if(id==g.error()) {
- std::cout << "FAIL " << __LINE__ << std::endl;
- BOOST_FAIL("unique");
- }
-// std::cout << "SUCCEED " << id << std::endl;
- BOOST_CHECK(used.count(id)==0);
- used.insert(id);
- }
-// std::cout << "inserted test_unique " << std::endl;
-// for (typename used_type::iterator it2=used.begin(), e=used.upper_bound()
-// ; it2!=e
-// ; ++it2) {
-// g.release(*it2);
-// }
-// std::cout << "END test_unique " << std::endl;
- g.clear();
-}
-
-template <typename G>
-void test_overflow(G& g) {
-// std::cout << "T." <<++i<< " test_overflow " << std::endl;
- typename G::numeric_type i;
- typename G::numeric_type id;
-// std::cout << "make test_overflow " << int(g.upper_bound()) << std::endl;
- for (i =g.lower_bound(); i<g.upper_bound(); ++i) {
- id =g.make();
- if(id==g.error()) {
- std::cout << "FAIL " << __LINE__ << std::endl;
- BOOST_FAIL("overflow");
- }
-// std::cout << "SUCCED " << __LINE__ << std::endl;
-
- }
-// std::cout << "check test_overflow " << std::endl;
- for (i =0; i<10; ++i) {
- BOOST_CHECK(g.make()==g.error());
- }
-// std::cout << "end test_overflow " << std::endl;
- g.clear();
-}
-
-template <typename G>
-void test_discard(G& g) {
-// std::cout << "T." <<++i<< " test_overflow " << std::endl;
- typename G::numeric_type i;
- typename G::numeric_type id;
-// std::cout << "make test_overflow " << int(g.upper_bound()) << std::endl;
- for (i =g.lower_bound(); i<g.upper_bound(); ++i) {
- id =g.make();
- if(id==g.error()) {
- std::cout << "FAIL " << __LINE__ << std::endl;
- BOOST_FAIL("overflow");
- }
-// std::cout << "SUCCED " << __LINE__ << std::endl;
-
- }
- g.release(id);
-
- typename G::numeric_type id2= g.make();
- BOOST_CHECK(id2==g.error());
-
- g.clear();
-}
-
-
-template <typename G>
-void test_overflow_throw(G& g) {
-// std::cout << "T." <<++i<< " test_overflow_throw " << std::endl;
- typename G::numeric_type i;
- for (i =g.lower_bound(); i<g.upper_bound(); ++i) {
- g.make();
- }
- for (i =0; i<10; ++i) {
- try {
- (void)g.make();
- BOOST_CHECK(false);
- } catch(...) {
- }
- }
-}
-
-template <typename G>
-void test_check(G& g) {
-// std::cout << "T." <<++i<< " test_check " << std::endl;
- typename G::numeric_type id1= g.make();
- g.release(id1);
-// std::cout << "test_check2 " << std::endl;
-
- try {
- g.release(id1);
- BOOST_CHECK(false);
- } catch(...) {
- }
-// std::cout << "test_check # " << g.count() << std::endl;
-
- g.clear();
-}
-
-#endif

Deleted: sandbox/synchro/libs/synchro/test/unit_test.hpp
==============================================================================
--- sandbox/synchro/libs/synchro/test/unit_test.hpp 2009-06-06 10:38:42 EDT (Sat, 06 Jun 2009)
+++ (empty file)
@@ -1,23 +0,0 @@
-//
-// unit_test.hpp
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
-//
-// 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)
-//
-
-#ifndef UNIT_TEST_HPP
-#define UNIT_TEST_HPP
-
-
-#include <boost/test/unit_test.hpp>
-#include <boost/test/included/unit_test_framework.hpp>
-using boost::unit_test::test_suite;
-
-inline void null_test()
-{
-}
-
-#endif // UNIT_TEST_HPP


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