Avoid lock for last queued command
Use atomics for last queued command update Change-Id: I759e9d78ea72f23c0d45dbede6250b231e122276
This commit is contained in:
@@ -192,25 +192,27 @@ bool HostQueue::isEmpty() {
|
||||
|
||||
void HostQueue::setLastQueuedCommand(Command* lastCommand) {
|
||||
// Set last submitted command
|
||||
ScopedLock l(lastCmdLock_);
|
||||
if (lastEnqueueCommand_ != nullptr) {
|
||||
lastEnqueueCommand_->release();
|
||||
Command* lastEnqueueCommand =
|
||||
lastEnqueueCommand_.exchange(lastCommand, std::memory_order_acq_rel);
|
||||
if (lastEnqueueCommand != nullptr) {
|
||||
lastEnqueueCommand->release();
|
||||
}
|
||||
lastEnqueueCommand_ = lastCommand;
|
||||
if (lastCommand != nullptr) {
|
||||
lastEnqueueCommand_->retain();
|
||||
lastCommand->retain();
|
||||
}
|
||||
}
|
||||
|
||||
Command* HostQueue::getLastQueuedCommand(bool retain) {
|
||||
// Get last submitted command
|
||||
ScopedLock l(lastCmdLock_);
|
||||
|
||||
if (retain && lastEnqueueCommand_ != nullptr) {
|
||||
lastEnqueueCommand_->retain();
|
||||
Command* lastEnqueueCommand = lastEnqueueCommand_.load(std::memory_order_acquire);
|
||||
if (lastEnqueueCommand == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return lastEnqueueCommand_;
|
||||
if (retain) {
|
||||
lastEnqueueCommand->retain();
|
||||
}
|
||||
return lastEnqueueCommand;
|
||||
}
|
||||
|
||||
DeviceQueue::~DeviceQueue() {
|
||||
|
||||
Reference in New Issue
Block a user