mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Convert mutex guard to "try lock"
This commit is contained in:
+9
-7
@@ -3925,13 +3925,15 @@ gb_internal i64 *type_set_offsets_of(Slice<Entity *> const &fields, bool is_pack
|
|||||||
gb_internal bool type_set_offsets(Type *t) {
|
gb_internal bool type_set_offsets(Type *t) {
|
||||||
t = base_type(t);
|
t = base_type(t);
|
||||||
if (t->kind == Type_Struct) {
|
if (t->kind == Type_Struct) {
|
||||||
MUTEX_GUARD(&t->Struct.offset_mutex);
|
if (mutex_try_lock(&t->Struct.offset_mutex)) {
|
||||||
if (!t->Struct.are_offsets_set) {
|
defer (mutex_unlock(&t->Struct.offset_mutex));
|
||||||
t->Struct.are_offsets_being_processed = true;
|
if (!t->Struct.are_offsets_set) {
|
||||||
t->Struct.offsets = type_set_offsets_of(t->Struct.fields, t->Struct.is_packed, t->Struct.is_raw_union, t->Struct.custom_min_field_align, t->Struct.custom_max_field_align);
|
t->Struct.are_offsets_being_processed = true;
|
||||||
t->Struct.are_offsets_being_processed = false;
|
t->Struct.offsets = type_set_offsets_of(t->Struct.fields, t->Struct.is_packed, t->Struct.is_raw_union, t->Struct.custom_min_field_align, t->Struct.custom_max_field_align);
|
||||||
t->Struct.are_offsets_set = true;
|
t->Struct.are_offsets_being_processed = false;
|
||||||
return true;
|
t->Struct.are_offsets_set = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (is_type_tuple(t)) {
|
} else if (is_type_tuple(t)) {
|
||||||
MUTEX_GUARD(&t->Tuple.mutex);
|
MUTEX_GUARD(&t->Tuple.mutex);
|
||||||
|
|||||||
Reference in New Issue
Block a user