2011-12-22 15:19:25 +00:00
|
|
|
/*
|
|
|
|
* \brief Locking primitives
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2006-07-26
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2012-01-03 14:35:05 +00:00
|
|
|
* Copyright (C) 2006-2012 Genode Labs GmbH
|
2011-12-22 15:19:25 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE__BASE__LOCK_H_
|
|
|
|
#define _INCLUDE__BASE__LOCK_H_
|
|
|
|
|
|
|
|
#include <base/cancelable_lock.h>
|
|
|
|
|
|
|
|
namespace Genode {
|
|
|
|
|
|
|
|
class Lock : public Cancelable_lock
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
|
|
|
explicit Lock(State initial = UNLOCKED)
|
|
|
|
: Cancelable_lock(initial) { }
|
|
|
|
|
|
|
|
void lock()
|
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
try {
|
|
|
|
Cancelable_lock::lock();
|
|
|
|
return;
|
|
|
|
} catch (Blocking_canceled) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Lock guard
|
|
|
|
*/
|
|
|
|
typedef Lock_guard<Lock> Guard;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _INCLUDE__BASE__LOCK_H_ */
|