Blender
V5.3
source
blender
blenlib
intern
session_uid.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_session_uid.hh
"
10
11
#include "
atomic_ops.h
"
12
13
namespace
blender
{
14
15
/* Denotes last used UID.
16
* It might eventually overflow, and easiest is to add more bits to it. */
17
static
SessionUID
global_session_uid
= detail::SESSION_UID_NONE;
18
19
SessionUID
BLI_session_uid_generate
()
20
{
21
SessionUID
result
;
22
result
.uid_ =
atomic_add_and_fetch_uint64
(&
global_session_uid
.
uid_
, 1);
23
if
(!
result
.is_generated()) {
24
/* Happens when the UID overflows.
25
*
26
* Just request the UID once again, hoping that there are not a lot of high-priority threads
27
* which will overflow the counter once again between the previous call and this one.
28
*
29
* NOTE: It is possible to have collisions after such overflow. */
30
result
.uid_ =
atomic_add_and_fetch_uint64
(&
global_session_uid
.
uid_
, 1);
31
}
32
return
result
;
33
}
34
35
}
// namespace blender
BLI_session_uid.hh
atomic_ops.h
Provides wrapper around system-specific atomic primitives, and some extensions (faked-atomic operatio...
atomic_add_and_fetch_uint64
ATOMIC_INLINE uint64_t atomic_add_and_fetch_uint64(uint64_t *p, uint64_t x)
Definition
atomic_ops_msvc.h:63
blender
BMesh Iterators.
Definition
ANIM_action.hh:30
blender::result
double result
Definition
BLI_expr_pylike_eval_test.cc:353
blender::BLI_session_uid_generate
SessionUID BLI_session_uid_generate()
Definition
session_uid.cc:19
blender::global_session_uid
static uint global_session_uid
Definition
lib_id.cc:1573
blender::SessionUID
Definition
DNA_session_uid_types.h:22
blender::SessionUID::uid_
uint64_t uid_
Definition
DNA_session_uid_types.h:27
Generated on
for Blender by
doxygen
1.18.0