Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a mechanism to "Transfer" JSObject between Workers #292

Merged
merged 19 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
28d5ec0
Add `JSObject.transfer` and `JSObject.receive` APIs
kateinoigakukun Mar 10, 2025
e406cd3
Stop hardcoding the Swift toolchain version in the Multithreading exa…
kateinoigakukun Mar 10, 2025
cfa1b2d
Update Multithreading example to support transferable objects
kateinoigakukun Mar 10, 2025
9d335a8
Add OffscreenCanvas example
kateinoigakukun Mar 10, 2025
98cec71
Rename `JSObject.receive` to `JSObject.Transferring.receive`
kateinoigakukun Mar 10, 2025
9b84176
Update test harness to support transferring
kateinoigakukun Mar 10, 2025
c481614
Fix JSObject lifetime issue while transferring
kateinoigakukun Mar 10, 2025
65ddcd3
Add basic tests for transferring objects between threads
kateinoigakukun Mar 10, 2025
f0bd60c
Fix native build
kateinoigakukun Mar 10, 2025
8d4bba6
Add cautionary notes to the documentation of `JSObject.transfer()`.
kateinoigakukun Mar 10, 2025
09d5311
Rename `JSObject.Transferring` to `JSTransferring<T>`
kateinoigakukun Mar 11, 2025
f25bfec
MessageBroker
kateinoigakukun Mar 11, 2025
58f91c3
Relax deinit requirement
kateinoigakukun Mar 11, 2025
2a081de
Remove dead code and fix error message
kateinoigakukun Mar 11, 2025
4fe37e7
Rename JSTransferring to JSSending
kateinoigakukun Mar 11, 2025
eeff111
Add `JSSending.receive(...)` to receive multiple objects at once
kateinoigakukun Mar 11, 2025
44a5dba
Build fix
kateinoigakukun Mar 11, 2025
b678f71
Skip multi-transfer tests
kateinoigakukun Mar 11, 2025
f5e3a95
Rename JSObject+Transferring.swift to JSSending.swift
kateinoigakukun Mar 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Stop hardcoding the Swift toolchain version in the Multithreading exa…
…mple
  • Loading branch information
kateinoigakukun committed Mar 10, 2025
commit e406cd3663255fe1761e8d8bb8287f7b75434bc8
16 changes: 14 additions & 2 deletions Examples/Multithreading/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
# Multithreading example

Install Development Snapshot toolchain `DEVELOPMENT-SNAPSHOT-2024-07-08-a` from [swift.org/install](https://www.swift.org/install/) and run the following commands:
Install Development Snapshot toolchain `DEVELOPMENT-SNAPSHOT-2024-07-08-a` or later from [swift.org/install](https://www.swift.org/install/) and run the following commands:

```sh
$ swift sdk install https://github.com/swiftwasm/swift/releases/download/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a/swift-wasm-DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasip1-threads.artifactbundle.zip
$ (
set -eo pipefail; \
V="$(swiftc --version | head -n1)"; \
TAG="$(curl -sL "https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/tag-by-version.json" | jq -e -r --arg v "$V" '.[$v] | .[-1]')"; \
curl -sL "https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/builds/$TAG.json" | \
jq -r '.["swift-sdks"]["wasm32-unknown-wasip1-threads"] | "swift sdk install \"\(.url)\" --checksum \"\(.checksum)\""' | sh -x
)
$ export SWIFT_SDK_ID=$(
V="$(swiftc --version | head -n1)"; \
TAG="$(curl -sL "https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/tag-by-version.json" | jq -e -r --arg v "$V" '.[$v] | .[-1]')"; \
curl -sL "https://raw.githubusercontent.com/swiftwasm/swift-sdk-index/refs/heads/main/v1/builds/$TAG.json" | \
jq -r '.["swift-sdks"]["wasm32-unknown-wasip1-threads"]["id"]'
)
$ ./build.sh
$ npx serve
```
2 changes: 1 addition & 1 deletion Examples/Multithreading/build.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
swift build --swift-sdk DEVELOPMENT-SNAPSHOT-2024-07-09-a-wasm32-unknown-wasip1-threads -Xswiftc -Xclang-linker -Xswiftc -mexec-model=reactor -Xlinker --export=__main_argc_argv -c release -Xswiftc -g
swift build --swift-sdk "${SWIFT_SDK_ID:-wasm32-unknown-wasip1-threads}" -Xswiftc -Xclang-linker -Xswiftc -mexec-model=reactor -Xlinker --export=__main_argc_argv -c release -Xswiftc -g