CAEN Utility  2.0.2
Utilities for CAEN projects
CAENThread.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * CAEN SpA - Software Division
4 * Via Vetraia, 11 - 55049 - Viareggio ITALY
5 * +39 0594 388 398 - www.caen.it
6 *
7 *******************************************************************************
8 *
9 * Copyright (C) 2019-2022 CAEN SpA
10 *
11 * This file is part of the CAEN Utility.
12 *
13 * The CAEN Utility is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 3 of the License, or (at your option) any later version.
17 *
18 * The CAEN Utility is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with the CAEN Utility; if not, see
25 * https://www.gnu.org/licenses/.
26 *
27 * SPDX-License-Identifier: LGPL-3.0-or-later
28 *
29 ***************************************************************************/
37 #ifndef CAEN_INCLUDE_CAENTHREAD_H_
38 #define CAEN_INCLUDE_CAENTHREAD_H_
39 
40 #include <stdbool.h>
41 #include <time.h>
42 
43 #include <types/CAENThreadTypes.h>
44 #include <CAENUtility.h>
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
54 
56 
57 c_acquires_lock_on_success(cond->_critical_section)
59 
60 c_releases_lock_on_success(cond->_critical_section)
62 
64 
66 
68 
142 
165 CAEN_UTILITY_DLLAPI int32_t CAEN_UTILITY_API c_thread_timedjoin(c_thread_t thr, int *res, int32_t timeout_ms);
206 CAEN_UTILITY_DLLAPI int32_t CAEN_UTILITY_API c_thread_sleep(const struct timespec* duration, struct timespec* remaining);
207 
212 CAEN_UTILITY_DLLAPI int32_t CAEN_UTILITY_API c_sleep(uint32_t ms);
224 #ifdef __cplusplus
225 }
226 #endif
227 
228 #endif // CAEN_INCLUDE_CAENTHREAD_H_
int32_t c_ticket_lock(c_ticket_t *ticket)
Definition: CAENThread.c:741
int32_t c_mutex_lock(c_mutex_t *m)
Definition: CAENThread.c:316
int32_t c_semaphore_destroy(c_semaphore_t *s)
Definition: CAENThread.c:215
int32_t c_condition_unlock(c_condition_t *cond)
Definition: CAENThread.c:448
#define CAEN_UTILITY_API
Definition: CAENUtility.h:104
int32_t c_semaphore_post(c_semaphore_t *s)
Definition: CAENThread.c:274
int32_t c_mutex_init(c_mutex_t *m)
Definition: CAENThread.c:288
int32_t c_semaphore_wait(c_semaphore_t *s, int32_t ms)
Definition: CAENThread.c:229
int32_t c_condition_broadcast(c_condition_t *cond)
Definition: CAENThread.c:519
#define c_releases_lock_on_success(m)
Definition: CAENUtility.h:269
Main header and generic tools.
int32_t c_mutex_destroy(c_mutex_t *m)
Definition: CAENThread.c:390
int32_t c_semaphore_init(c_semaphore_t *s)
Definition: CAENThread.c:181
Ticket type.
int32_t c_ticket_init(c_ticket_t *ticket)
Definition: CAENThread.c:719
int32_t c_thread_create(c_thread_t *thr, c_tstart_t func, void *arg)
Definition: CAENThread.c:621
int32_t c_sleep(uint32_t ms)
Definition: CAENThread.c:566
int32_t c_ticket_unlock(c_ticket_t *ticket)
Definition: CAENThread.c:775
#define CAEN_UTILITY_DLLAPI
Definition: CAENUtility.h:105
int32_t c_condition_lock(c_condition_t *cond)
Definition: CAENThread.c:439
c_thread_t c_thread_current(void)
Definition: CAENThread.c:100
int32_t c_thread_detach(c_thread_t thr)
Definition: CAENThread.c:127
c_thread_t c_thread_invalid()
Definition: CAENThread.c:609
#define c_nodiscard
Definition: CAENUtility.h:245
void c_thread_exit(int res)
Definition: CAENThread.c:147
#define c_noreturn
Definition: CAENUtility.h:258
#define c_acquires_lock_on_success(m)
Definition: CAENUtility.h:268
int32_t c_thread_join(c_thread_t thr, int *res)
Definition: CAENThread.c:654
int32_t c_ticket_delete(c_ticket_t *ticket)
Definition: CAENThread.c:725
int32_t c_mutex_trylock(c_mutex_t *m)
Definition: CAENThread.c:340
void c_thread_yield(void)
Definition: CAENThread.c:112
sem_t c_semaphore_t
Semaphore type.
int32_t c_condition_destroy(c_condition_t *cond)
Definition: CAENThread.c:427
int32_t c_condition_wait(c_condition_t *cond, int32_t ms)
Definition: CAENThread.c:457
int32_t c_condition_init(c_condition_t *cond)
Definition: CAENThread.c:414
pthread_mutex_t c_mutex_t
Mutex type.
int32_t c_semaphore_multi_init(c_semaphore_t *s)
Definition: CAENThread.c:198
int(* c_tstart_t)(void *)
Thread function type, as defined in C11.
int32_t c_thread_setaffinity(c_thread_t thr, uint64_t mask)
Definition: CAENThread.c:68
int32_t c_thread_sleep(const struct timespec *duration, struct timespec *remaining)
Definition: CAENThread.c:537
int32_t c_mutex_unlock(c_mutex_t *m)
Definition: CAENThread.c:367
bool c_thread_equal(c_thread_t lhs, c_thread_t rhs)
Definition: CAENThread.c:155
int32_t c_condition_signal_one(c_condition_t *cond)
Definition: CAENThread.c:501
int32_t c_thread_timedjoin(c_thread_t thr, int *res, int32_t timeout_ms)
Definition: CAENThread.c:658
Needed because a condition variable on Linux is associated with a mutex, while on Windows it is assoc...
Definitions and types for CAENThreadTypes.h.