20 #include "LockQueue.hpp"
21 #include "SimulatedBlock.hpp"
28 const bool exclusive = ! (req->requestInfo & UtilLockReq::SharedLock);
29 const bool trylock = req->requestInfo & UtilLockReq::TryLock;
30 const bool notify = req->requestInfo & UtilLockReq::Notify;
36 if (queue.last(lockEPtr))
39 if (! (lockEPtr.p->m_req.requestInfo & UtilLockReq::SharedLock))
49 else if (lockEPtr.p->m_req.requestInfo & UtilLockReq::Granted)
61 if(trylock && grant ==
false)
64 if (notify && lockOwner)
67 queue.first(lockEPtr);
68 * lockOwner = &lockEPtr.p->m_req;
70 return UtilLockRef::LockAlreadyHeld;
73 if(!thePool.seize(lockEPtr))
76 return UtilLockRef::OutOfLockRecords;
79 lockEPtr.p->m_req = *req;
80 queue.addLast(lockEPtr);
85 lockEPtr.p->m_req.requestInfo |= UtilLockReq::Granted;
86 return UtilLockRef::OK;
91 return UtilLockRef::InLockQueue;
100 const Uint32 senderRef = req->senderRef;
101 const Uint32 senderData = req->senderData;
106 for (queue.first(lockEPtr); !lockEPtr.isNull(); queue.next(lockEPtr))
109 if (lockEPtr.p->m_req.senderData == senderData &&
110 lockEPtr.p->m_req.senderRef == senderRef)
115 if (lockEPtr.p->m_req.requestInfo & UtilLockReq::Granted)
118 res = UtilUnlockRef::OK;
123 res = UtilUnlockRef::NotLockOwner;
125 queue.release(lockEPtr);
130 return UtilUnlockRef::NotInLockQueue;
135 Pool& thePool, Iterator & iter)
138 if (queue.first(iter.m_curr))
140 iter.m_block =
block;
141 iter.m_prev.setNull();
142 iter.thePool = &thePool;
149 LockQueue::next(Iterator& iter)
151 iter.m_prev = iter.m_curr;
153 return queue.next(iter.m_curr);
161 if (iter.m_prev.isNull())
163 if (iter.m_curr.p->m_req.requestInfo & UtilLockReq::Granted)
171 * req = iter.m_curr.p->m_req;
172 iter.m_curr.p->m_req.requestInfo |= UtilLockReq::Granted;
182 assert(iter.m_prev.p->m_req.requestInfo & UtilLockReq::Granted);
183 if (iter.m_prev.p->m_req.requestInfo & UtilLockReq::SharedLock)
186 if (iter.m_curr.p->m_req.requestInfo & UtilLockReq::SharedLock)
189 if (iter.m_curr.p->m_req.requestInfo & UtilLockReq::Granted)
197 * req = iter.m_curr.p->m_req;
198 iter.m_curr.p->m_req.requestInfo |= UtilLockReq::Granted;
214 #include "SimulatedBlock.hpp"
222 for (queue.
first(ptr); !ptr.isNull(); queue.
next(ptr))
225 block->
infoEvent(
"- sender: 0x%x data: %u %s %s extra: %u",
226 ptr.p->m_req.senderRef,
227 ptr.p->m_req.senderData,
228 (ptr.p->m_req.requestInfo & UtilLockReq::SharedLock) ?
230 (ptr.p->m_req.requestInfo & UtilLockReq::Granted) ?