pthread_spin.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
22 #ifdef __cplusplus
23 #include <atomic>
24 using std::atomic_flag;
25 #else
26 #include <stdatomic.h>
27 #endif
28 
35 typedef struct {
36  atomic_flag flag;
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
52 int pthread_spin_init(pthread_spinlock_t *lock, int pshared);
53 
64 
73 
83 
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
int pthread_spin_unlock(pthread_spinlock_t *lock)
Releases a spinlock.
int pthread_spin_lock(pthread_spinlock_t *lock)
Lock a spinlock.
int pthread_spin_destroy(pthread_spinlock_t *lock)
Destroys a spinlock.
int pthread_spin_init(pthread_spinlock_t *lock, int pshared)
Initializes a spinlock.
int pthread_spin_trylock(pthread_spinlock_t *lock)
Tries to lock a spinlock, returns immediately if already locked.
atomic_flag flag
Current lock state.
Definition: pthread_spin.h:36