Loading...
Searching...
No Matches
pthread_spin.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
18
19#ifdef __cplusplus
20#include <atomic>
21using std::atomic_flag;
22#else
23#include <stdatomic.h>
24#endif
25
32typedef struct {
33 atomic_flag flag;
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
49int pthread_spin_init(pthread_spinlock_t *lock, int pshared);
50
61
70
80
90
91#ifdef __cplusplus
92}
93#endif
94
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.