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