libcamera v0.1.0+127-8e215127-dirty (2023-12-02T01:06:12+00:00)
Supporting cameras in Linux since 2019
message.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 * message.h - Message queue support
6 */
7
8#pragma once
9
10#include <atomic>
11
12#include <libcamera/base/private.h>
13
15
16namespace libcamera {
17
18class BoundMethodBase;
19class Object;
20class Semaphore;
21class Thread;
22
24{
25public:
26 enum Type {
27 None = 0,
32 };
33
35 virtual ~Message();
36
37 Type type() const { return type_; }
38 Object *receiver() const { return receiver_; }
39
41
42private:
43 friend class Thread;
44
45 Type type_;
46 Object *receiver_;
47
48 static std::atomic_uint nextUserType_;
49};
50
51class InvokeMessage : public Message
52{
53public:
54 InvokeMessage(BoundMethodBase *method,
55 std::shared_ptr<BoundMethodPackBase> pack,
56 Semaphore *semaphore = nullptr,
57 bool deleteMethod = false);
59
60 Semaphore *semaphore() const { return semaphore_; }
61
62 void invoke();
63
64private:
65 BoundMethodBase *method_;
66 std::shared_ptr<BoundMethodPackBase> pack_;
67 Semaphore *semaphore_;
68 bool deleteMethod_;
69};
70
71} /* namespace libcamera */
Method bind and invocation.
A message carrying a method invocation across threads.
Definition: message.h:52
Semaphore * semaphore() const
Retrieve the message semaphore passed to the constructor.
Definition: message.h:60
void invoke()
Invoke the method bound to InvokeMessage::method_ with arguments InvokeMessage::pack_.
Definition: message.cpp:151
A message that can be posted to a Thread.
Definition: message.h:24
Object * receiver() const
Retrieve the message receiver.
Definition: message.h:38
Type type() const
Retrieve the message type.
Definition: message.h:37
Type
The message type.
Definition: message.h:26
@ DeferredDelete
Object is scheduled for deletion.
Definition: message.h:30
@ None
Invalid message type.
Definition: message.h:27
@ InvokeMessage
Asynchronous method invocation across threads.
Definition: message.h:28
@ ThreadMoveMessage
Object is being moved to a different thread.
Definition: message.h:29
@ UserMessage
First value available for user-defined messages.
Definition: message.h:31
Message(Type type)
Construct a message object of type type.
Definition: message.cpp:61
static Type registerMessageType()
Reserve and register a custom user-defined message type.
Definition: message.cpp:109
Base object to support automatic signal disconnection.
Definition: object.h:25
General-purpose counting semaphore.
Definition: semaphore.h:17
A thread of execution.
Definition: thread.h:29
Top-level libcamera namespace.
Definition: backtrace.h:17