Boost logo

Boost :

From: Eric D Crahen (crahen_at_[hidden])
Date: 2002-05-16 12:41:44


I've only just started following this list, and I haven't read all of
the messages in the past regarding this topic, so you have my
apologies if I'm a bit off.

> I don't know a whole lot about threads and locking, but I would be
> happy to try to create a smart pointer policy for ScopedLock.

In ZThreads, I'm using a Guard template that uses policies to control
how a lock is acquire()d and release()d and the order in which these
things happen. Its pretty useful for dealing with nested scoped
locks. Here's a brief example,

class aClass {

  Mutex lock;

  void func() {

    // Guard<Mutex> does the same, ForwardLocking is the default policy.

    Guard<Mutex, ForwardLocking> g(lock);

    // 'lock' is locked

    { // 'lock' is unlocked
        Guard<Mutex, BackwardLocking> temporarily_unlock(lock);

    }

    // 'lock' is locked

  }

};

The policies I'm using a really pretty simple, and not nearly as robust
as what I've seen in boost. There is a link on my web page if you want to
play around with it.

- Eric
http://www.cse.buffalo.edu/~crahen


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