Files
external_libcamera/src/libcamera/include/message.h
Laurent Pinchart 5a954cb8b5 libcamera: object: Notify objects of thread move
Send a synchronous message to objects just before they get moved to a
new thread. This allows the object to perform any required processing.
EventNotifier and Timer objects will use this mechanism to move
themselves to the new thread's event disaptcher.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-08-17 18:32:30 +03:00

65 lines
1.0 KiB
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* message.h - Message queue support
*/
#ifndef __LIBCAMERA_MESSAGE_H__
#define __LIBCAMERA_MESSAGE_H__
#include <atomic>
#include <libcamera/bound_method.h>
namespace libcamera {
class BoundMethodBase;
class Object;
class Thread;
class Message
{
public:
enum Type {
None = 0,
InvokeMessage = 1,
ThreadMoveMessage = 2,
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, void *pack,
bool deleteMethod = false);
~InvokeMessage();
void invoke();
private:
BoundMethodBase *method_;
void *pack_;
bool deleteMethod_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_MESSAGE_H__ */