Blender
V5.0
source
blender
blenlib
intern
cache_mutex.cc
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
#include "
BLI_cache_mutex.hh
"
10
#include "
BLI_task.hh
"
11
12
namespace
blender
{
13
14
void
CacheMutex::ensure_impl(
const
FunctionRef
<
void
()> compute_cache)
15
{
16
if
(cache_valid_.load(std::memory_order_acquire)) {
17
return
;
18
}
19
std::scoped_lock
lock
{mutex_};
20
/* Double checked lock. */
21
if
(cache_valid_.load(std::memory_order_relaxed)) {
22
return
;
23
}
24
/* Use task isolation because a mutex is locked and the cache computation might use
25
* multi-threading. */
26
threading::isolate_task
(compute_cache);
27
28
cache_valid_.store(
true
, std::memory_order_release);
29
}
30
31
}
// namespace blender
BLI_cache_mutex.hh
BLI_task.hh
lock
volatile int lock
Definition
atomic_ops_unix.h:0
blender::FunctionRef
Definition
BLI_function_ref.hh:72
blender::threading::isolate_task
void isolate_task(const Function &function)
Definition
BLI_task.hh:248
blender
Definition
ANIM_action.hh:36
Generated on
for Blender by
doxygen
1.16.1