Forgot to include this file in the previous commit.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17454 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-05-14 14:30:25 +00:00
parent 973d499ee1
commit 382ef632d7

View File

@ -54,4 +54,31 @@ release_lock(struct lock *lock)
return B_OK;
}
class Autolock {
public:
Autolock(struct lock &lock)
:
fLock(&lock)
{
fStatus = acquire_lock(fLock);
}
~Autolock()
{
if (fStatus == B_OK)
release_lock(fLock);
}
bool
IsLocked()
{
return fStatus == B_OK;
}
private:
status_t fStatus;
struct lock *fLock;
};
#endif /* LOCK_H */