Blender
V4.5
source
blender
blenlib
BLI_cache_mutex.hh
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2023 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9
#pragma once
10
64
65
#include <atomic>
66
67
#include "
BLI_function_ref.hh
"
68
#include "
BLI_mutex.hh
"
69
70
namespace
blender
{
71
72
class
CacheMutex
{
73
private
:
74
Mutex
mutex_;
75
std::atomic<bool> cache_valid_ =
false
;
76
77
public
:
85
void
ensure
(
FunctionRef
<
void
()> compute_cache);
86
90
void
tag_dirty
()
91
{
92
cache_valid_.store(
false
);
93
}
94
98
bool
is_dirty
()
const
99
{
100
return
!this->
is_cached
();
101
}
102
106
bool
is_cached
()
const
107
{
108
return
cache_valid_.load(std::memory_order_relaxed);
109
}
110
};
111
112
}
// namespace blender
BLI_function_ref.hh
BLI_mutex.hh
blender::CacheMutex
Definition
BLI_cache_mutex.hh:72
blender::CacheMutex::tag_dirty
void tag_dirty()
Definition
BLI_cache_mutex.hh:90
blender::CacheMutex::is_dirty
bool is_dirty() const
Definition
BLI_cache_mutex.hh:98
blender::CacheMutex::is_cached
bool is_cached() const
Definition
BLI_cache_mutex.hh:106
blender::CacheMutex::ensure
void ensure(FunctionRef< void()> compute_cache)
Definition
cache_mutex.cc:14
blender::FunctionRef
Definition
BLI_function_ref.hh:72
blender
Definition
ANIM_action.hh:36
blender::Mutex
std::mutex Mutex
Definition
BLI_mutex.hh:47
Generated on
for Blender by
doxygen
1.15.0