Files
external_libcamera/include/libcamera/base/semaphore.h
Kieran Bingham e228c290c9 libcamera/base: Validate internal headers as private
Headers which must not be exposed as part of the public libcamera API
should include base/private.h.

Any interface which includes the private.h header will only be able to
build if the libcamera_private dependency is used (or the
libcamera_base_private dependency directly).

Build targets which are intended to use the private API's will use the
libcamera_private to handle the automatic definition of the inclusion
guard.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-06-25 16:11:11 +01:00

36 lines
703 B
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* semaphore.h - General-purpose counting semaphore
*/
#ifndef __LIBCAMERA_BASE_SEMAPHORE_H__
#define __LIBCAMERA_BASE_SEMAPHORE_H__
#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 */
#endif /* __LIBCAMERA_BASE_SEMAPHORE_H__ */