| 357 | } |
| 358 | |
| 359 | Command* HostQueue::getLastQueuedCommand(bool retain) { |
| 360 | if (AMD_DIRECT_DISPATCH) { |
| 361 | // The batch update must be lock protected to avoid a race condition |
| 362 | // when multiple threads submit/flush/update the batch at the same time |
| 363 | ScopedLock sl(vdev()->execution()); |
| 364 | // Since the lastCmdLock_ is acquired, it is safe to read and retain the lastEnqueueCommand. |
| 365 | // It is guaranteed that the pointer will not change. |
| 366 | if (retain && lastEnqueueCommand_ != nullptr) { |
| 367 | lastEnqueueCommand_->retain(); |
| 368 | } |
| 369 | return lastEnqueueCommand_; |
| 370 | } else { |
| 371 | // Get last submitted command |
| 372 | ScopedLock l(lastCmdLock_); |
| 373 | |
| 374 | // Since the lastCmdLock_ is acquired, it is safe to read and retain the lastEnqueueCommand. |
| 375 | // It is guaranteed that the pointer will not change. |
| 376 | if (retain && lastEnqueueCommand_ != nullptr) { |
| 377 | lastEnqueueCommand_->retain(); |
| 378 | } |
| 379 | return lastEnqueueCommand_; |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | DeviceQueue::~DeviceQueue() { |
| 384 | delete virtualDevice_; |
no test coverage detected