From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2006-06-02 08:26:38


Vladimir Frolov wrote:

>Hello, All
>
>I have finished implementation of Lwsync library, which contains two
>patterns to organize synchronization on concurrent environment. I
>would like to propose to include this library into Boost.
>
>Lwsync library can be mapped on any threading facilities and by
>default it is mapped on Boost.Thread ones.
>
>Is there any interest in this library?
>
>
Although we have a quite a few concurrency libraries in the vault and in
development, I always think that each one provides an interesting
perspective.

Just one comment about yours:

>Example 2:
>typedef monitor<std::vector<int> > monitor_vector_t;
>bool is_not_empty(const std::vector<int>& test_vector)
>{
> return !test_vector.empty();
>}
>
>monitor_vector_t monitor_vector;
>
>thread 1:
>{
> monitor_vector_t::accessor vector_access =
> monitor_vector.wait_for(is_not_empty);
> // Do something with non-empty vector here.
>}
>
>thread 2:
>monitor_vector.access()->push_back(10);
>
>
I think wait_for() should return a lock object on the monitor's
resource. Otherwise, the vector could be emptied again before thread 1
gets to execute anything. (Only each individual access is locked in your
system.)
Generally, there should be a way to obtain a lock for a resource that
outlasts a single call.
If this is implemented as I guess it is, you might also suffer from the
not clearly defined temporary destruction semantics.

Sebastian Redl