Blender V5.0
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.h"
10
11#include "atomic_ops.h"
12
13/* Special value which indicates the UID has not been assigned yet. */
14#define BLI_session_uid_NONE 0
15
17
18/* Denotes last used UID.
19 * It might eventually overflow, and easiest is to add more bits to it. */
21
23{
27 /* Happens when the UID overflows.
28 *
29 * Just request the UID once again, hoping that there are not a lot of high-priority threads
30 * which will overflow the counter once again between the previous call and this one.
31 *
32 * NOTE: It is possible to have collisions after such overflow. */
34 }
35 return result;
36}
37
42
44{
45 return lhs->uid_ == rhs->uid_;
46}
47
49{
50 return uid->uid_;
51}
52
54{
55 const SessionUID *uid = (const SessionUID *)uid_v;
56 return uid->uid_ & 0xffffffff;
57}
58
59bool BLI_session_uid_ghash_compare(const void *lhs_v, const void *rhs_v)
60{
61 const SessionUID *lhs = (const SessionUID *)lhs_v;
62 const SessionUID *rhs = (const SessionUID *)rhs_v;
63 return !BLI_session_uid_is_equal(lhs, rhs);
64}
unsigned int uint
Provides wrapper around system-specific atomic primitives, and some extensions (faked-atomic operatio...
ATOMIC_INLINE uint64_t atomic_add_and_fetch_uint64(uint64_t *p, uint64_t x)
unsigned long long int uint64_t
static uint global_session_uid
Definition lib_id.cc:1475
bool BLI_session_uid_is_equal(const SessionUID *lhs, const SessionUID *rhs)
SessionUID BLI_session_uid_generate()
bool BLI_session_uid_is_generated(const SessionUID *uid)
uint BLI_session_uid_ghash_hash(const void *uid_v)
bool BLI_session_uid_ghash_compare(const void *lhs_v, const void *rhs_v)
uint64_t BLI_session_uid_hash_uint64(const SessionUID *uid)
static const SessionUID global_session_uid_none
#define BLI_session_uid_NONE