On 10/9/06, Ovidiu Ciule <[EMAIL PROTECTED]> wrote:
Hello,

The util/Logger.h header contains this declaration: mutable boost::mutex _mutex;

and the .cpp:
void Logger::log(Level level, const std::string & className, const
std::string & message) {
        boost::mutex::scoped_lock scopedLock(_mutex);
...

What purpose does this lock serve? I understand mutex mechanisms,
semaphores etc.
What I cannot see here is the shared ressource that is protected by
this lock, nor what makes this lock necessary.


WengoPhone logging routines are among those which can be called at any
time by any thread and, as such, they require proper sinchronization,
one common example found in any operating systems book out there to
explain concurrent programming is a routine printing some text called
by two threads asynchronously, without that mutex, one thread might
start to print a message while another thread is writing another
message, and since stdout is a shared resource, the output would be at
the very least unreadable
_______________________________________________
Wengophone-devel mailing list
[email protected]
http://dev.openwengo.com/mailman/listinfo/wengophone-devel

Reply via email to