Boost logo

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:

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)
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, kalb at, bjorn.karlsson at, gregod at, wekempf at