decrease graph context ref count by 1
| 57 | |
| 58 | // decrease graph context ref count by 1 |
| 59 | inline void GraphContext_DecreaseRefCount |
| 60 | ( |
| 61 | GraphContext *gc |
| 62 | ) { |
| 63 | ASSERT(gc != NULL); |
| 64 | |
| 65 | // if the reference count is 0 |
| 66 | // the graph has been marked for deletion and no queries are active |
| 67 | // free the graph |
| 68 | if(__atomic_sub_fetch(&gc->ref_count, 1, __ATOMIC_RELAXED) == 0) { |
| 69 | bool async_delete; |
| 70 | Config_Option_get(Config_ASYNC_DELETE, &async_delete); |
| 71 | |
| 72 | if(async_delete) { |
| 73 | // Async delete |
| 74 | // add deletion task to pool using force mode |
| 75 | // we can't lose this task in-case pool's queue is full |
| 76 | ThreadPools_AddWorkWriter(_GraphContext_Free, gc, 1); |
| 77 | } else { |
| 78 | // Sync delete |
| 79 | _GraphContext_Free(gc); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | //------------------------------------------------------------------------------ |
| 85 | // GraphContext API |