| 249 | } |
| 250 | |
| 251 | void recompui::destroy_context(ContextId id) { |
| 252 | bool existed = false; |
| 253 | |
| 254 | // TODO prevent deletion of a context while its mutex is in use. Second lock on the context's mutex before popping |
| 255 | // from the slotmap? |
| 256 | |
| 257 | // Check if the provided id exists. |
| 258 | { |
| 259 | std::lock_guard lock{ context_state.all_contexts_lock }; |
| 260 | // Check if the target context is currently open. |
| 261 | existed = context_state.all_contexts.has_key(context_slotmap::key{ id.slot_id }); |
| 262 | } |
| 263 | |
| 264 | |
| 265 | // Raise an error if the context didn't exist. |
| 266 | if (!existed) { |
| 267 | context_error(id, ContextErrorType::DestroyInvalidContext); |
| 268 | } |
| 269 | |
| 270 | id.open(); |
| 271 | id.clear_children(); |
| 272 | id.close(); |
| 273 | |
| 274 | // Delete the provided id. |
| 275 | { |
| 276 | std::lock_guard lock{ context_state.all_contexts_lock }; |
| 277 | context_state.all_contexts.erase(context_slotmap::key{ id.slot_id }); |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | void recompui::destroy_all_contexts() { |
| 282 | recompui::hide_all_contexts(); |
nothing calls this directly
no test coverage detected