Blender  V3.3
session_uuid.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include "BLI_session_uuid.h"
8 
9 #include "BLI_utildefines.h"
10 
11 #include "atomic_ops.h"
12 
13 /* Special value which indicates the UUID has not been assigned yet. */
14 #define BLI_SESSION_UUID_NONE 0
15 
17 
18 /* Denotes last used UUID.
19  * It might eventually overflow, and easiest is to add more bits to it. */
21 
23 {
27  /* Happens when the UUID overflows.
28  *
29  * Just request the UUID 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 
39 {
41 }
42 
44 {
45  return lhs->uuid_ == rhs->uuid_;
46 }
47 
49 {
50  return uuid->uuid_;
51 }
52 
53 uint BLI_session_uuid_ghash_hash(const void *uuid_v)
54 {
55  const SessionUUID *uuid = (const SessionUUID *)uuid_v;
56  return uuid->uuid_ & 0xffffffff;
57 }
58 
59 bool BLI_session_uuid_ghash_compare(const void *lhs_v, const void *rhs_v)
60 {
61  const SessionUUID *lhs = (const SessionUUID *)lhs_v;
62  const SessionUUID *rhs = (const SessionUUID *)rhs_v;
63  return !BLI_session_uuid_is_equal(lhs, rhs);
64 }
unsigned int uint
Definition: BLI_sys_types.h:67
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)
uint64_t BLI_session_uuid_hash_uint64(const SessionUUID *uuid)
Definition: session_uuid.c:48
bool BLI_session_uuid_ghash_compare(const void *lhs_v, const void *rhs_v)
Definition: session_uuid.c:59
SessionUUID BLI_session_uuid_generate(void)
Definition: session_uuid.c:22
uint BLI_session_uuid_ghash_hash(const void *uuid_v)
Definition: session_uuid.c:53
bool BLI_session_uuid_is_equal(const SessionUUID *lhs, const SessionUUID *rhs)
Definition: session_uuid.c:43
static SessionUUID global_session_uuid
Definition: session_uuid.c:20
#define BLI_SESSION_UUID_NONE
Definition: session_uuid.c:14
static const SessionUUID global_session_uuid_none
Definition: session_uuid.c:16
bool BLI_session_uuid_is_generated(const SessionUUID *uuid)
Definition: session_uuid.c:38
unsigned __int64 uint64_t
Definition: stdint.h:90