Sha256: b627bbb38d961797fa775e6964ad17631ab9fec4992f787070dcda78a066efa3

Contents?: true

Size: 595 Bytes

Versions: 9

Compression:

Stored size: 595 Bytes

Contents

#ifndef _PASSENGER_LOCK_H_
#define _PASSENGER_LOCK_H_

#include <boost/thread.hpp>

namespace Passenger {

using namespace boost;

/** Shortcut typedefs. */
typedef lock_guard<boost::mutex> LockGuard;
typedef 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

9 entries across 9 versions & 1 rubygems

Version Path
passenger-4.0.5 ext/common/Utils/Lock.h
passenger-4.0.4 ext/common/Utils/Lock.h
passenger-4.0.3 ext/common/Utils/Lock.h
passenger-4.0.2 ext/common/Utils/Lock.h
passenger-4.0.1 ext/common/Utils/Lock.h
passenger-4.0.0.rc6 ext/common/Utils/Lock.h
passenger-4.0.0.rc4 ext/common/Utils/Lock.h
passenger-3.9.2.beta ext/common/Utils/Lock.h
passenger-3.9.1.beta ext/common/Utils/Lock.h