Blender
V4.3
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
5
#pragma once
6
61
#include <atomic>
62
#include <mutex>
63
64
#include "
BLI_function_ref.hh
"
65
66
namespace
blender
{
67
68
class
CacheMutex
{
69
private
:
70
std::mutex mutex_;
71
std::atomic<bool> cache_valid_ =
false
;
72
73
public
:
81
void
ensure
(
FunctionRef
<
void
()> compute_cache);
82
86
void
tag_dirty
()
87
{
88
cache_valid_.store(
false
);
89
}
90
94
bool
is_dirty
()
const
95
{
96
return
!this->
is_cached
();
97
}
98
102
bool
is_cached
()
const
103
{
104
return
cache_valid_.load(std::memory_order_relaxed);
105
}
106
};
107
108
}
// namespace blender
BLI_function_ref.hh
blender::CacheMutex
Definition
BLI_cache_mutex.hh:68
blender::CacheMutex::tag_dirty
void tag_dirty()
Definition
BLI_cache_mutex.hh:86
blender::CacheMutex::is_dirty
bool is_dirty() const
Definition
BLI_cache_mutex.hh:94
blender::CacheMutex::is_cached
bool is_cached() const
Definition
BLI_cache_mutex.hh:102
blender::CacheMutex::ensure
void ensure(FunctionRef< void()> compute_cache)
Definition
cache_mutex.cc:10
blender::FunctionRef
Definition
BLI_function_ref.hh:74
blender
Definition
ANIM_action.hh:36
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0