libcamera/base: Move extended base functionality

Move the functionality for the following components to the new
base support library:

 - BoundMethod
 - EventDispatcher
 - EventDispatcherPoll
 - Log
 - Message
 - Object
 - Signal
 - Semaphore
 - Thread
 - Timer

While it would be preferable to see these split to move one component
per commit, these components are all interdependent upon each other,
which leaves us with one big change performing the move for all of them.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Kieran Bingham
2021-06-15 16:15:12 +01:00
parent 6410d1d37c
commit 27aff949fb
161 changed files with 390 additions and 366 deletions
+71
View File
@@ -0,0 +1,71 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* message.h - Message queue support
*/
#ifndef __LIBCAMERA_BASE_MESSAGE_H__
#define __LIBCAMERA_BASE_MESSAGE_H__
#include <atomic>
#include <libcamera/base/bound_method.h>
namespace libcamera {
class BoundMethodBase;
class Object;
class Semaphore;
class Thread;
class Message
{
public:
enum Type {
None = 0,
InvokeMessage = 1,
ThreadMoveMessage = 2,
DeferredDelete = 3,
UserMessage = 1000,
};
Message(Type type);
virtual ~Message();
Type type() const { return type_; }
Object *receiver() const { return receiver_; }
static Type registerMessageType();
private:
friend class Thread;
Type type_;
Object *receiver_;
static std::atomic_uint nextUserType_;
};
class InvokeMessage : public Message
{
public:
InvokeMessage(BoundMethodBase *method,
std::shared_ptr<BoundMethodPackBase> pack,
Semaphore *semaphore = nullptr,
bool deleteMethod = false);
~InvokeMessage();
Semaphore *semaphore() const { return semaphore_; }
void invoke();
private:
BoundMethodBase *method_;
std::shared_ptr<BoundMethodPackBase> pack_;
Semaphore *semaphore_;
bool deleteMethod_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_BASE_MESSAGE_H__ */