Skip to content

Commit 7cb1cc1

Browse files
committed
Fix stylo compile on wasm
Signed-off-by: Nico Burns <[email protected]>
1 parent 9b0806a commit 7cb1cc1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

style/global_style_data.rs

+20
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ pub type PlatformThreadHandle = RawPthread;
2525
#[cfg(windows)]
2626
pub type PlatformThreadHandle = RawHandle;
2727

28+
/// A noop thread join handle for wasm
29+
/// The usize field is a dummy field to make this type non-zero sized so as not to confuse FFI
30+
#[cfg(target_arch = "wasm32")]
31+
pub struct DummyThreadHandle(#[allow(dead_code)] usize);
32+
#[cfg(target_arch = "wasm32")]
33+
impl DummyThreadHandle {
34+
/// A noop thread join method for wasm
35+
pub fn join(&self) {
36+
// Do nothing
37+
}
38+
}
39+
#[cfg(target_arch = "wasm32")]
40+
/// Platform-specific handle to a thread.
41+
pub type PlatformThreadHandle = DummyThreadHandle;
42+
2843
/// Global style data
2944
pub struct GlobalStyleData {
3045
/// Shared RWLock for CSSOM objects
@@ -131,6 +146,11 @@ impl StyleThreadPool {
131146
let handle = join_handle.as_pthread_t();
132147
#[cfg(windows)]
133148
let handle = join_handle.as_raw_handle();
149+
#[cfg(target_arch = "wasm32")]
150+
let handle = {
151+
let _ = join_handle;
152+
DummyThreadHandle(0)
153+
};
134154

135155
handles.push(handle);
136156
}

0 commit comments

Comments
 (0)