11cb0ef41Sopenharmony_ci/* MIT License
21cb0ef41Sopenharmony_ci *
31cb0ef41Sopenharmony_ci * Copyright (c) 2023 Brad House
41cb0ef41Sopenharmony_ci *
51cb0ef41Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
61cb0ef41Sopenharmony_ci * of this software and associated documentation files (the "Software"), to deal
71cb0ef41Sopenharmony_ci * in the Software without restriction, including without limitation the rights
81cb0ef41Sopenharmony_ci * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
91cb0ef41Sopenharmony_ci * copies of the Software, and to permit persons to whom the Software is
101cb0ef41Sopenharmony_ci * furnished to do so, subject to the following conditions:
111cb0ef41Sopenharmony_ci *
121cb0ef41Sopenharmony_ci * The above copyright notice and this permission notice (including the next
131cb0ef41Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
141cb0ef41Sopenharmony_ci * Software.
151cb0ef41Sopenharmony_ci *
161cb0ef41Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
171cb0ef41Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
181cb0ef41Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
191cb0ef41Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
201cb0ef41Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
211cb0ef41Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
221cb0ef41Sopenharmony_ci * SOFTWARE.
231cb0ef41Sopenharmony_ci *
241cb0ef41Sopenharmony_ci * SPDX-License-Identifier: MIT
251cb0ef41Sopenharmony_ci */
261cb0ef41Sopenharmony_ci#ifndef __ARES__THREADS_H
271cb0ef41Sopenharmony_ci#define __ARES__THREADS_H
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_cistruct ares__thread_mutex;
301cb0ef41Sopenharmony_citypedef struct ares__thread_mutex ares__thread_mutex_t;
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ciares__thread_mutex_t             *ares__thread_mutex_create(void);
331cb0ef41Sopenharmony_civoid ares__thread_mutex_destroy(ares__thread_mutex_t *mut);
341cb0ef41Sopenharmony_civoid ares__thread_mutex_lock(ares__thread_mutex_t *mut);
351cb0ef41Sopenharmony_civoid ares__thread_mutex_unlock(ares__thread_mutex_t *mut);
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_cistruct ares__thread_cond;
391cb0ef41Sopenharmony_citypedef struct ares__thread_cond ares__thread_cond_t;
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ciares__thread_cond_t             *ares__thread_cond_create(void);
421cb0ef41Sopenharmony_civoid          ares__thread_cond_destroy(ares__thread_cond_t *cond);
431cb0ef41Sopenharmony_civoid          ares__thread_cond_signal(ares__thread_cond_t *cond);
441cb0ef41Sopenharmony_civoid          ares__thread_cond_broadcast(ares__thread_cond_t *cond);
451cb0ef41Sopenharmony_ciares_status_t ares__thread_cond_wait(ares__thread_cond_t  *cond,
461cb0ef41Sopenharmony_ci                                     ares__thread_mutex_t *mut);
471cb0ef41Sopenharmony_ciares_status_t ares__thread_cond_timedwait(ares__thread_cond_t  *cond,
481cb0ef41Sopenharmony_ci                                          ares__thread_mutex_t *mut,
491cb0ef41Sopenharmony_ci                                          unsigned long         timeout_ms);
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_cistruct ares__thread;
531cb0ef41Sopenharmony_citypedef struct ares__thread ares__thread_t;
541cb0ef41Sopenharmony_ci
551cb0ef41Sopenharmony_citypedef void               *(*ares__thread_func_t)(void *arg);
561cb0ef41Sopenharmony_ciares_status_t               ares__thread_create(ares__thread_t    **thread,
571cb0ef41Sopenharmony_ci                                                ares__thread_func_t func, void *arg);
581cb0ef41Sopenharmony_ciares_status_t ares__thread_join(ares__thread_t *thread, void **rv);
591cb0ef41Sopenharmony_ci
601cb0ef41Sopenharmony_ci#endif
61