elmesque
elmesque copied to clipboard
Make `guid()` thread safe
Currently it mutates a static variable:
/// The global graphics unique identifier counter.
pub type Guid = u64;
pub static mut GUID: Guid = 0;
/// Increment the GUID and return the new GUID.
fn guid() -> Guid {
unsafe {
GUID += 1; // <--- two threads can increment this at once
GUID // <--- the two threads receive the same id
}
}
@bvssvni indeed, however I don't even think the Guid is even being used by anything (Element stores one, however I don't think it is ever used). We could probably just get rid of it.