forked from realsenseai/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcallback-invocation.h
More file actions
67 lines (50 loc) · 1.62 KB
/
callback-invocation.h
File metadata and controls
67 lines (50 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2021 Intel Corporation. All Rights Reserved.
#pragma once
#include "small-heap.h"
#include <chrono>
namespace librealsense {
struct callback_invocation
{
std::chrono::high_resolution_clock::time_point started;
std::chrono::high_resolution_clock::time_point ended;
};
typedef small_heap< callback_invocation, 1 > callbacks_heap;
struct callback_invocation_holder
{
callback_invocation_holder()
: invocation( nullptr )
, owner( nullptr )
{
}
callback_invocation_holder( const callback_invocation_holder & ) = delete;
callback_invocation_holder & operator=( const callback_invocation_holder & ) = delete;
callback_invocation_holder( callback_invocation_holder && other )
: invocation( other.invocation )
, owner( other.owner )
{
other.invocation = nullptr;
}
callback_invocation_holder( callback_invocation * invocation, callbacks_heap * owner )
: invocation( invocation )
, owner( owner )
{
}
~callback_invocation_holder()
{
if( invocation )
owner->deallocate( invocation );
}
callback_invocation_holder & operator=( callback_invocation_holder && other )
{
invocation = other.invocation;
owner = other.owner;
other.invocation = nullptr;
return *this;
}
operator bool() { return invocation != nullptr; }
private:
callback_invocation * invocation;
callbacks_heap * owner;
};
} // namespace librealsense