分类:
2010-04-14 17:29:37
boost::lock_guard
构造是获得锁,析构时候放弃锁
boost::lock_guard is very simple: on construction it acquires ownership of the implementation of the Lockable concept supplied as the constructor parameter. On destruction, the ownership is released. This provides simple RAII-style locking of a Lockable object, to facilitate exception-safe locking and unlocking. In addition, the lock_guard(Lockable & m,boost::adopt_lock_t) constructor allows the boost::lock_guard object to take ownership of a lock already held by the current thread.
Stores a reference to m. Invokes m.lock().
Throws:Any exception thrown by the call to m.lock().