Use a dedicated lock for last queued command set/get

Change-Id: If3d2144841c7863cf7afe2ca85aea62e0a3a33c7


[ROCm/clr commit: 0782acabb5]
This commit is contained in:
Christophe Paquot
2020-05-27 17:15:58 -07:00
parent 75e59b010a
commit 992fbe8215
2 changed files with 6 additions and 6 deletions
@@ -192,7 +192,7 @@ bool HostQueue::isEmpty() {
void HostQueue::setLastQueuedCommand(Command* lastCommand) {
// Set last submitted command
ScopedLock sl(queueLock_);
ScopedLock l(lastCmdLock_);
if (lastEnqueueCommand_ != nullptr) {
lastEnqueueCommand_->release();
}
@@ -204,14 +204,12 @@ void HostQueue::setLastQueuedCommand(Command* lastCommand) {
Command* HostQueue::getLastQueuedCommand(bool retain) {
// Get last submitted command
ScopedLock sl(queueLock_);
if (lastEnqueueCommand_ == nullptr) {
return nullptr;
}
ScopedLock l(lastCmdLock_);
if (retain) {
if (retain && lastEnqueueCommand_ != nullptr) {
lastEnqueueCommand_->retain();
}
return lastEnqueueCommand_;
}
@@ -126,6 +126,7 @@ class CommandQueue : public RuntimeObject {
rtCUs_(rtCUs),
priority_(priority),
queueLock_("CommandQueue::queueLock"),
lastCmdLock_("LastQueuedCommand"),
device_(device),
context_(context),
cuMask_(cuMask){}
@@ -134,6 +135,7 @@ class CommandQueue : public RuntimeObject {
uint rtCUs_; //!< The number of used RT compute units
Priority priority_; //!< Queue priority
Monitor queueLock_; //!< Lock protecting the queue
Monitor lastCmdLock_; //!< Lock protecting the last queued command
Device& device_; //!< The device
SharedReference<Context> context_; //!< The context of this command queue
const std::vector<uint32_t>& cuMask_; //!< The CU mask