| 294 | } |
| 295 | |
| 296 | XRTMemoryManager::DeviceContext* XRTMemoryManager::GetDeviceContext( |
| 297 | int device_ordinal, bool create_if_missing) { |
| 298 | mutex_lock lock(lock_); |
| 299 | if (device_ordinal >= device_contexts_.size()) { |
| 300 | if (!create_if_missing) { |
| 301 | return nullptr; |
| 302 | } |
| 303 | device_contexts_.resize(device_ordinal + 1); |
| 304 | } |
| 305 | DeviceContext* device_context = device_contexts_[device_ordinal].get(); |
| 306 | if (device_context == nullptr && create_if_missing) { |
| 307 | device_contexts_[device_ordinal] = absl::make_unique<DeviceContext>(); |
| 308 | device_context = device_contexts_[device_ordinal].get(); |
| 309 | } |
| 310 | return device_context; |
| 311 | } |
| 312 | |
| 313 | Status XRTMemoryManager::TryFreeMemoryStep(MemoryReclaimContext* mrctx, |
| 314 | const Status& status) { |