Blender V4.3
session_uid.c
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
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{
26 if (!BLI_session_uid_is_generated(&result)) {
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)
local_group_size(16, 16) .push_constant(Type rhs
bool BLI_session_uid_is_equal(const SessionUID *lhs, const SessionUID *rhs)
Definition session_uid.c:43
static SessionUID global_session_uid
Definition session_uid.c:20
bool BLI_session_uid_is_generated(const SessionUID *uid)
Definition session_uid.c:38
uint BLI_session_uid_ghash_hash(const void *uid_v)
Definition session_uid.c:53
bool BLI_session_uid_ghash_compare(const void *lhs_v, const void *rhs_v)
Definition session_uid.c:59
uint64_t BLI_session_uid_hash_uint64(const SessionUID *uid)
Definition session_uid.c:48
SessionUID BLI_session_uid_generate(void)
Definition session_uid.c:22
static const SessionUID global_session_uid_none
Definition session_uid.c:16
#define BLI_session_uid_NONE
Definition session_uid.c:14
unsigned __int64 uint64_t
Definition stdint.h:90