#ifndef NET_FS_LOCKABLE_H
#define NET_FS_LOCKABLE_H
#include <util/DoublyLinkedList.h>
#include "Blocker.h"
class LockerCandidate : public DoublyLinkedListLinkImpl<LockerCandidate> {
public:
LockerCandidate(Blocker blocker);
thread_id GetThread() const;
status_t Block();
status_t Unblock(bool success);
private:
Blocker fBlocker;
thread_id fThread;
};
typedef DoublyLinkedList<LockerCandidate> LockerCandidateList;
class Lockable {
public:
Lockable();
~Lockable();
bool Lock();
void Unlock();
bool IsLocked() const;
void QueueLockerCandidate(
LockerCandidate* candidate);
private:
LockerCandidateList fLockerCandidates;
thread_id fLockOwner;
int32 fLockCounter;
};
#endif