|
Boost Users : |
Subject: Re: [Boost-users] question about threading library
From: Roman Shmelev (rshmelev_at_[hidden])
Date: 2008-11-06 16:27:11
Hi! Here are simple examples:
1.
boost::mutex m;
// non-thread safe commands
{
// non-thread safe commands
boost::mutex::scoped_lock L (m);
// thread safe commands
} // on exiting scope the L is destroyed and so mutex _m_ is
AUTO-unlocked. very convenient!
// non-thread safe commands
2. boost::shared_mutex shm;
can be locked with boost::unique_lock<boost::shared_mutex> ul (shm)
or
boost::shared_lock<boost::shared_mutex> ul (shm)
so this implements single_writer/multiple_readers concept
Hope this will help you to understand threads :)
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net