| 86 | } |
| 87 | |
| 88 | void ISimpleLifetimeManager::end_lifetime(void *obj, IMemory &obj_memory, size_t size, size_t alignment) |
| 89 | { |
| 90 | ARM_COMPUTE_ERROR_ON(obj == nullptr); |
| 91 | |
| 92 | // Find object |
| 93 | auto active_object_it = _active_elements.find(obj); |
| 94 | ARM_COMPUTE_ERROR_ON(active_object_it == std::end(_active_elements)); |
| 95 | |
| 96 | // Update object fields and mark object as complete |
| 97 | Element &el = active_object_it->second; |
| 98 | el.handle = &obj_memory; |
| 99 | el.size = size; |
| 100 | el.alignment = alignment; |
| 101 | el.status = true; |
| 102 | |
| 103 | // Find object in the occupied lists |
| 104 | auto occupied_blob_it = std::find_if(std::begin(_occupied_blobs), std::end(_occupied_blobs), |
| 105 | [&obj](const Blob &b) { return obj == b.id; }); |
| 106 | ARM_COMPUTE_ERROR_ON(occupied_blob_it == std::end(_occupied_blobs)); |
| 107 | |
| 108 | // Update occupied blob and return as free |
| 109 | occupied_blob_it->bound_elements.insert(obj); |
| 110 | occupied_blob_it->max_size = std::max(occupied_blob_it->max_size, size); |
| 111 | occupied_blob_it->max_alignment = std::max(occupied_blob_it->max_alignment, alignment); |
| 112 | occupied_blob_it->id = nullptr; |
| 113 | _free_blobs.splice(std::begin(_free_blobs), _occupied_blobs, occupied_blob_it); |
| 114 | |
| 115 | // Check if all objects are finalized and reset active group |
| 116 | if (are_all_finalized()) |
| 117 | { |
| 118 | ARM_COMPUTE_ERROR_ON(!_occupied_blobs.empty()); |
| 119 | |
| 120 | // Update blobs and group mappings |
| 121 | update_blobs_and_mappings(); |
| 122 | |
| 123 | // Update finalized groups |
| 124 | _finalized_groups[_active_group].insert(std::begin(_active_elements), std::end(_active_elements)); |
| 125 | |
| 126 | // Reset state |
| 127 | _active_elements.clear(); |
| 128 | _active_group = nullptr; |
| 129 | _free_blobs.clear(); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | bool ISimpleLifetimeManager::are_all_finalized() const |
| 134 | { |
no test coverage detected