Loading...
Searching...
No Matches
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
20#ifndef PTHREAD_SPIN_H
21#define PTHREAD_SPIN_H
22
23#ifdef __cplusplus
24#include <atomic>
25using std::atomic_flag;
26#else
27#include <stdatomic.h>
28#endif
29
36typedef struct {
37 atomic_flag flag;
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
53int pthread_spin_init(pthread_spinlock_t *lock, int pshared);
54
65
74
84
94
95#ifdef __cplusplus
96}
97#endif
98
99#endif /* PTHREAD_SPIN_H */
100
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.