Crate web_thread
source ·Expand description
TODO:
- Re-factor builder implementation.
- Add
MessageSend
macro. - Add
WorkletBuilder
(or useBuilder
). - Wrap
MessageChannel
into something safe. - Consider passing message into
Builder
. - Add README.
- Consider moving some APIs into
web-thread-core/primitives
.
Things to note:
- Will fail on import when used with the
no-modules
target. - Blocking is not recommended, e.g. blocks events.
- Audio worklets are very limited, e.g. should not do any allocation.
- Spawning happens on the “main” thread, e.g. if blocked nothing will spawn (affects some browsers only).
- Calling any functions from a thread not spawned by
web-thread
will cause issues.
Browser bugs:
- Browsers don’t support
TextEncoder
/TextDecoder
in audio worklets:- Chrome: ?
- Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1826432
- Safari: ?
- Firefox doesn’t support module service workers: https://bugzilla.mozilla.org/show_bug.cgi?id=1360870.
- Browsers don’t support blocking in shared workers:
- Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1359745
- Safari: ?
- Spec doesn’t allow cross-origin isolation in shared and service workers: https://github.com/w3c/ServiceWorker/pull/1545.
- Browsers don’t support spawning and blocking afterwards (e.g.
spawn(..).join()
):- Chrome:
- Spawning: https://issues.chromium.org/issues/40633395
postMessage()
: https://issues.chromium.org/issues/40687798
- Safari: ?
- Chrome:
- Browsers don’t properly shutdown audio worklet when state is
closed
:- Chrome: https://issues.chromium.org/issues/40072701
- Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1878516
- Safari: ?
- Headless browsers seem to have some issues when spawning too many threads:
- Firefox: ?
- Safari: ?
- Headless Firefox can’t run
AudioContext
without a real audio device: https://bugzilla.mozilla.org/show_bug.cgi?id=1881904. - Chrome fails to send
WebAssembly.Module
overAudioWorkletNode.port
: https://issues.chromium.org/issues/40855462.
Modules§
- web
Web
Platform-specific extensions forweb-thread
on the Web platform.
Structs§
- An error returned by
LocalKey::try_with
. - See
std::thread::Builder
. - A thread local storage key which owns its contents.
- See
std::thread::Scope
. - See
std::thread::Thread
.
Functions§
- Determines whether the current thread is unwinding because of panic.
- See
std::thread::park()
. - park_
timeout_ ms Deprecated - See
std::thread::scope()
. - See
std::thread::sleep()
. - sleep_
ms Deprecated - See
std::thread::spawn()
. - sleep_
until Experimental Puts the current thread to sleep until the specified deadline has passed.
Type Aliases§
- A specialized
Result
type for threads.