Files
external_libcamera/include/libcamera/base/semaphore.h
Kieran Bingham 0701f756b9 libcamera: base: Convert to pragma once
Remove the verbose #ifndef/#define/#endif pattern for maintaining
header idempotency, and replace it with a simple #pragma once.

This simplifies the headers, and prevents redundant changes when
header files get moved.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
2021-11-24 12:18:11 +00:00

34 lines
594 B
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* semaphore.h - General-purpose counting semaphore
*/
#pragma once
#include <condition_variable>
#include <libcamera/base/private.h>
#include <libcamera/base/thread.h>
namespace libcamera {
class Semaphore
{
public:
Semaphore(unsigned int n = 0);
unsigned int available();
void acquire(unsigned int n = 1);
bool tryAcquire(unsigned int n = 1);
void release(unsigned int n = 1);
private:
Mutex mutex_;
std::condition_variable cv_;
unsigned int available_;
};
} /* namespace libcamera */