Boost logo

Boost :

From: Vladimir Frolov (voidbent_at_[hidden])
Date: 2006-06-02 07:34:47


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 provides critical resource and monitor patterns. Critical
resource synchronizes all accesses to specific resource and
automatically invokes locking and unlocking methods before and after
each access. Monitor pattern is a kind of critical resource which not
only synchronizes all accesses but also allows one to wait until
resource becomes in defined state.
One can use Lwsync patterns like this:

Example 1:
typedef critical_resource<std::vector<int> > critical_vector_t;
critical_vector_t critical_vector;

critical_resource<std::ostream&> sync_cout(std::cout);

critical_vector.access()->push_back(10);

{
   critical_vector_t::const_accessor vector_access = critical_vector;
   for(size_t i = 0; i < vector_access->size(); ++i)
      *sync_cout.access() << "Index : " << i
          << ", Data : " << (*vector_access)[i] << std::endl;
}

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);

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?

---
With respect,
Vladimir Frolov

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk