Lines Matching refs:c

97     void create_coroutine(coroutine_type& c, std::size_t stack_size, void* arg);
98 void current_coroutine(coroutine_type& c);
100 void destroy_coroutine(coroutine_type& c);
174 coroutine_type& c = data.first; in coroutine_thread_func() local
177 std::unique_lock<std::mutex> lock(c.my_mutex); in coroutine_thread_func()
178 __TBB_ASSERT(c.my_thread_data == nullptr, nullptr); in coroutine_thread_func()
179 c.my_is_active = false; in coroutine_thread_func()
183 c.my_condvar.notify_one(); in coroutine_thread_func()
185 c.my_condvar.wait(lock, [&c] { return c.my_is_active == true; }); in coroutine_thread_func()
187 __TBB_ASSERT(c.my_thread_data != nullptr, nullptr); in coroutine_thread_func()
188 governor::set_thread_data(*c.my_thread_data); in coroutine_thread_func()
206 inline void create_coroutine(coroutine_type& c, std::size_t stack_size, void* arg) { in create_coroutine() argument
207 thread_data_t data{ c, arg }; in create_coroutine()
210c.my_thread = (HANDLE)_beginthreadex(nullptr, unsigned(stack_size), coroutine_thread_func, &data, … in create_coroutine()
211 if (!c.my_thread) { in create_coroutine()
220 …check(pthread_create(&c.my_thread, &s, coroutine_thread_func, &data), "pthread_create has failed"); in create_coroutine()
225 std::unique_lock<std::mutex> lock(c.my_mutex); in create_coroutine()
226 c.my_condvar.wait(lock, [&arg] { return arg == nullptr; }); in create_coroutine()
229 inline void current_coroutine(coroutine_type& c) { in current_coroutine() argument
231 c.my_thread = GetCurrentThread(); in current_coroutine()
233 c.my_thread = pthread_self(); in current_coroutine()
263 inline void destroy_coroutine(coroutine_type& c) { in destroy_coroutine() argument
265 std::unique_lock<std::mutex> lock(c.my_mutex); in destroy_coroutine()
266 __TBB_ASSERT(c.my_thread_data == nullptr, "The sleeping thread should not be active"); in destroy_coroutine()
267 __TBB_ASSERT(c.my_is_active == false, "The sleeping thread should not be active"); in destroy_coroutine()
268 c.my_is_active = true; in destroy_coroutine()
269 c.my_condvar.notify_one(); in destroy_coroutine()
272 WaitForSingleObject(c.my_thread, INFINITE); in destroy_coroutine()
273 CloseHandle(c.my_thread); in destroy_coroutine()
275 check(pthread_join(c.my_thread, nullptr), "pthread_join has failed"); in destroy_coroutine()
279 inline void create_coroutine(coroutine_type& c, std::size_t stack_size, void* arg) { in create_coroutine() argument
281 c = CreateFiber(stack_size, co_local_wait_for_all, arg); in create_coroutine()
282 __TBB_ASSERT(c, nullptr); in create_coroutine()
285 inline void current_coroutine(coroutine_type& c) { in current_coroutine() argument
286 c = IsThreadAFiber() ? GetCurrentFiber() : in current_coroutine()
288 __TBB_ASSERT(c, nullptr); in current_coroutine()
301 inline void destroy_coroutine(coroutine_type& c) { in destroy_coroutine() argument
302 __TBB_ASSERT(c, nullptr); in destroy_coroutine()
303 DeleteFiber(c); in destroy_coroutine()
307 inline void create_coroutine(coroutine_type& c, std::size_t stack_size, void* arg) { in create_coroutine() argument
321 c.my_stack = (void*)(stack_ptr + REG_PAGE_SIZE); in create_coroutine()
322 c.my_stack_size = page_aligned_stack_size; in create_coroutine()
324 err = getcontext(&c.my_context); in create_coroutine()
327 c.my_context.uc_link = nullptr; in create_coroutine()
329 c.my_context.uc_stack.ss_sp = (char*)c.my_stack; in create_coroutine()
330 c.my_context.uc_stack.ss_size = c.my_stack_size; in create_coroutine()
331 c.my_context.uc_stack.ss_flags = 0; in create_coroutine()
340 makecontext(&c.my_context, (coroutine_func_t)co_local_wait_for_all, 2, hi, lo); in create_coroutine()
343 inline void current_coroutine(coroutine_type& c) { in current_coroutine() argument
344 int err = getcontext(&c.my_context); in current_coroutine()
353 inline void destroy_coroutine(coroutine_type& c) { in destroy_coroutine() argument
356 … munmap((void*)((std::uintptr_t)c.my_stack - REG_PAGE_SIZE), c.my_stack_size + 2 * REG_PAGE_SIZE); in destroy_coroutine()
358 c.my_stack = nullptr; in destroy_coroutine()
359 c.my_stack_size = 0; in destroy_coroutine()