int cilk_fiber::deallocate_from_thread() { CILK_ASSERT(this->is_allocated_from_thread()); #if SUPPORT_GET_CURRENT_FIBER CILK_ASSERT(this == cilkos_get_tls_cilk_fiber()); // Reverse of "allocate_from_thread". cilkos_set_tls_cilk_fiber(NULL); #endif this->assert_ref_count_at_least(2); // Suspending the fiber should conceptually decrement the ref // count by 1. cilk_fiber_sysdep* self = this->sysdep(); self->convert_fiber_back_to_thread(); // Then, freeing the fiber itself decrements the ref count again. int ref_count = this->sub_from_ref_count(2); if (ref_count == 0) { self->~cilk_fiber_sysdep(); __cilkrts_free(self); } return ref_count; }
cilk_fiber_sysdep* cilk_fiber_sysdep::get_current_fiber_sysdep() { return cilkos_get_tls_cilk_fiber(); }