Adds the given handle at the index position, by marking it releasable according to the release argument. If an existing, and to-be-released handle already exists at the same index, it will be released.
| 52 | // according to the release argument. If an existing, and to-be-released |
| 53 | // handle already exists at the same index, it will be released. |
| 54 | Status Add(size_t index, int64 handle, bool release) { |
| 55 | if (index >= handles_.size()) { |
| 56 | handles_.resize(index + 1, XRTMemoryManager::InvalidKey()); |
| 57 | handles_release_.resize(index + 1, false); |
| 58 | } |
| 59 | if (handles_release_[index]) { |
| 60 | Status status = memory_manager_->Release(handles_[index]); |
| 61 | if (!status.ok()) { |
| 62 | if (release) { |
| 63 | memory_manager_->Release(handle).IgnoreError(); |
| 64 | } |
| 65 | return status; |
| 66 | } |
| 67 | } |
| 68 | handles_[index] = handle; |
| 69 | handles_release_[index] = release; |
| 70 | return Status::OK(); |
| 71 | } |
| 72 | |
| 73 | // Adds a to-be-released tuple allocation at the given index. |
| 74 | Status Add(size_t index, RefPtr<XRTTupleAllocation> tuple) { |
no test coverage detected