Sha256: 2bb88633dfc4be15193a7b8c8f576a83f5c04ed3d67b9bdbf1954d28184a3320

Contents?: true

Size: 609 Bytes

Versions: 11

Compression:

Stored size: 609 Bytes

Contents

#ifndef _PASSENGER_LOCK_H_
#define _PASSENGER_LOCK_H_

#include <boost/thread.hpp>

namespace Passenger {

using namespace boost;

/** Shortcut typedefs. */
typedef boost::lock_guard<boost::mutex> LockGuard;
typedef boost::unique_lock<boost::mutex> ScopedLock;

/** Nicer syntax for conditionally locking the mutex during construction. */
class DynamicScopedLock: public unique_lock<boost::mutex> {
public:
	DynamicScopedLock(boost::mutex &m, bool lockNow = true)
		: unique_lock<boost::mutex>(m, defer_lock)
	{
		if (lockNow) {
			lock();
		}
	}
};

} // namespace Passenger

#endif /* _PASSENGER_LOCK_H_ */

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
passenger-4.0.20 ext/common/Utils/Lock.h
passenger-4.0.19 ext/common/Utils/Lock.h
passenger-4.0.18 ext/common/Utils/Lock.h
passenger-4.0.17 ext/common/Utils/Lock.h
passenger-4.0.16 ext/common/Utils/Lock.h
passenger-4.0.14 ext/common/Utils/Lock.h
passenger-4.0.13 ext/common/Utils/Lock.h
passenger-4.0.10 ext/common/Utils/Lock.h
passenger-4.0.8 ext/common/Utils/Lock.h
passenger-4.0.7 ext/common/Utils/Lock.h
passenger-4.0.6 ext/common/Utils/Lock.h