libcamera
v0.7.2
Supporting cameras in Linux since 2019
Toggle main menu visibility
Loading...
Searching...
No Matches
semaphore.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2
/*
3
* Copyright (C) 2019, Google Inc.
4
*
5
* General-purpose counting semaphore
6
*/
7
8
#pragma once
9
10
#include <libcamera/base/private.h>
11
12
#include <
libcamera/base/mutex.h
>
13
14
namespace
libcamera
{
15
16
class
Semaphore
17
{
18
public
:
19
Semaphore
(
unsigned
int
n = 0);
20
21
unsigned
int
available
() LIBCAMERA_TSA_EXCLUDES(mutex_);
22
void
acquire
(
unsigned
int
n = 1) LIBCAMERA_TSA_EXCLUDES(mutex_);
23
bool
tryAcquire
(
unsigned
int
n = 1) LIBCAMERA_TSA_EXCLUDES(mutex_);
24
void
release
(
unsigned
int
n = 1) LIBCAMERA_TSA_EXCLUDES(mutex_);
25
26
private
:
27
Mutex
mutex_;
28
ConditionVariable
cv_;
29
unsigned
int
available_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
30
};
31
32
}
/* namespace libcamera */
libcamera::ConditionVariable
std::condition_variable wrapper integrating with MutexLocker
Definition
mutex.h:122
libcamera::Mutex
std::mutex wrapper with clang thread safety annotation
Definition
mutex.h:114
libcamera::Semaphore::release
void release(unsigned int n=1) LIBCAMERA_TSA_EXCLUDES(mutex_)
Release n resources.
Definition
semaphore.cpp:94
libcamera::Semaphore::acquire
void acquire(unsigned int n=1) LIBCAMERA_TSA_EXCLUDES(mutex_)
Acquire n resources.
Definition
semaphore.cpp:56
libcamera::Semaphore::available
unsigned int available() LIBCAMERA_TSA_EXCLUDES(mutex_)
Retrieve the number of available resources.
Definition
semaphore.cpp:42
libcamera::Semaphore::Semaphore
Semaphore(unsigned int n=0)
Construct a semaphore with n resources.
Definition
semaphore.cpp:33
libcamera::Semaphore::tryAcquire
bool tryAcquire(unsigned int n=1) LIBCAMERA_TSA_EXCLUDES(mutex_)
Try to acquire n resources without blocking.
Definition
semaphore.cpp:76
mutex.h
Mutex classes with clang thread safety annotation.
libcamera
Top-level libcamera namespace.
Definition
backtrace.h:17
include
libcamera
base
semaphore.h
Generated by
1.18.0