From 7e5064ac1b259f5f92a588fc42096337c2f37a1c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 26 Feb 2023 14:01:56 -0700 Subject: [PATCH] [wasm-shape] Comment re thread-safety --- src/hb-wasm-shape.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/hb-wasm-shape.cc b/src/hb-wasm-shape.cc index 5e43ff96b..25b35cbcc 100644 --- a/src/hb-wasm-shape.cc +++ b/src/hb-wasm-shape.cc @@ -114,7 +114,14 @@ struct hb_wasm_face_data_t { static bool _hb_wasm_init () { - /* XXX Umm. Make this threadsafe. How?! */ + /* XXX + * + * Umm. Make this threadsafe. How?! + * It's clunky that we can't allocate a static mutex. + * So we have to first allocate one on the heap atomically... + * + * Also, wasm-micro-runtime uses a singleton instance. So if + * another library or client uses it, all bets are off. :-( */ static bool initialized; if (initialized) @@ -140,8 +147,8 @@ _hb_wasm_init () } #ifndef HB_WASM_NO_MODULES - wasm_runtime_set_module_reader(_hb_wasm_module_reader, - _hb_wasm_module_destroyer); + wasm_runtime_set_module_reader (_hb_wasm_module_reader, + _hb_wasm_module_destroyer); #endif initialized = true;