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:
parent
973d499ee1
commit
382ef632d7
@ -54,4 +54,31 @@ release_lock(struct lock *lock)
|
|||||||
return B_OK;
|
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 */
|
#endif /* LOCK_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user