libcamera v0.0.0+3240-f2a18172-dirty (2022-05-13T12:20:20+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#ifndef __LIBCAMERA_BASE_MESSAGE_H__
8#define __LIBCAMERA_BASE_MESSAGE_H__
9
10#include <atomic>
11
13
14namespace libcamera {
15
16class BoundMethodBase;
17class Object;
18class Semaphore;
19class Thread;
20
22{
23public:
24 enum Type {
25 None = 0,
30 };
31
33 virtual ~Message();
34
35 Type type() const { return type_; }
36 Object *receiver() const { return receiver_; }
37
39
40private:
41 friend class Thread;
42
43 Type type_;
44 Object *receiver_;
45
46 static std::atomic_uint nextUserType_;
47};
48
49class InvokeMessage : public Message
50{
51public:
52 InvokeMessage(BoundMethodBase *method,
53 std::shared_ptr<BoundMethodPackBase> pack,
54 Semaphore *semaphore = nullptr,
55 bool deleteMethod = false);
57
58 Semaphore *semaphore() const { return semaphore_; }
59
60 void invoke();
61
62private:
63 BoundMethodBase *method_;
64 std::shared_ptr<BoundMethodPackBase> pack_;
65 Semaphore *semaphore_;
66 bool deleteMethod_;
67};
68
69} /* namespace libcamera */
70
71#endif /* __LIBCAMERA_BASE_MESSAGE_H__ */
Method bind and invocation.
A message carrying a method invocation across threads.
Definition: message.h:50
Semaphore * semaphore() const
Retrieve the message semaphore passed to the constructor.
Definition: message.h:58
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:22
Object * receiver() const
Retrieve the message receiver.
Definition: message.h:36
Type type() const
Retrieve the message type.
Definition: message.h:35
Type
The message type.
Definition: message.h:24
@ DeferredDelete
Object is scheduled for deletion.
Definition: message.h:28
@ None
Invalid message type.
Definition: message.h:25
@ InvokeMessage
Asynchronous method invocation across threads.
Definition: message.h:26
@ ThreadMoveMessage
Object is being moved to a different thread.
Definition: message.h:27
@ UserMessage
First value available for user-defined messages.
Definition: message.h:29
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:18
A thread of execution.
Definition: thread.h:33
Top-level libcamera namespace.
Definition: backtrace.h:17