GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Concurrency: Fix build for p1-threads target · rarestype/JavaScriptKit@bf58616

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Sources/_CJavaScriptEventLoop/include
    • _CJavaScriptEventLoop.h
  • Tests/JavaScriptEventLoopTests
    • WebWorkerTaskExecutorTests.swift
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Sources/_CJavaScriptEventLoop/include/_CJavaScriptEventLoop.h‎

Copy file name to clipboardExpand all lines: Sources/_CJavaScriptEventLoop/include/_CJavaScriptEventLoop.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ extern void *_Nullable swift_task_asyncMainDrainQueue_hook SWIFT_NONISOLATED_UNS
6666

6767
/// MARK: - thread local storage
6868

69-
extern _Thread_local void * _Nullable swjs_thread_local_event_loop;
69+
extern _Thread_local void * _Nullable swjs_thread_local_event_loop SWIFT_NONISOLATED_UNSAFE;
7070

7171
extern _Thread_local void * _Nullable swjs_thread_local_task_executor_worker SWIFT_NONISOLATED_UNSAFE;
7272

Collapse file

‎Tests/JavaScriptEventLoopTests/WebWorkerTaskExecutorTests.swift‎

Copy file name to clipboardExpand all lines: Tests/JavaScriptEventLoopTests/WebWorkerTaskExecutorTests.swift
+17-19Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import _CJavaScriptKit // For swjs_get_worker_thread_id
88
func isMainThread() -> Bool
99

1010
final class WebWorkerTaskExecutorTests: XCTestCase {
11-
override func setUp() {
12-
WebWorkerTaskExecutor.installGlobalExecutor()
11+
override func setUp() async {
12+
await WebWorkerTaskExecutor.installGlobalExecutor()
1313
}
1414

1515
func testTaskRunOnMainThread() async throws {
@@ -152,48 +152,46 @@ final class WebWorkerTaskExecutorTests: XCTestCase {
152152

153153
func testThreadLocalPerThreadValues() async throws {
154154
struct Check {
155-
@ThreadLocal(boxing: ())
156-
static var value: Int?
155+
static let value = ThreadLocal<Int>(boxing: ())
157156
}
158157
let executor = try await WebWorkerTaskExecutor(numberOfThreads: 1)
159-
XCTAssertNil(Check.value)
160-
Check.value = 42
161-
XCTAssertEqual(Check.value, 42)
158+
XCTAssertNil(Check.value.wrappedValue)
159+
Check.value.wrappedValue = 42
160+
XCTAssertEqual(Check.value.wrappedValue, 42)
162161

163162
let task = Task(executorPreference: executor) {
164-
XCTAssertEqual(Check.value, nil)
165-
Check.value = 100
166-
XCTAssertEqual(Check.value, 100)
167-
return Check.value
163+
XCTAssertNil(Check.value.wrappedValue)
164+
Check.value.wrappedValue = 100
165+
XCTAssertEqual(Check.value.wrappedValue, 100)
166+
return Check.value.wrappedValue
168167
}
169168
let result = await task.value
170169
XCTAssertEqual(result, 100)
171-
XCTAssertEqual(Check.value, 42)
170+
XCTAssertEqual(Check.value.wrappedValue, 42)
172171
executor.terminate()
173172
}
174173

175174
func testLazyThreadLocalPerThreadInitialization() async throws {
176175
struct Check {
177-
static var valueToInitialize = 42
178-
static var countOfInitialization = 0
179-
@LazyThreadLocal(initialize: {
176+
nonisolated(unsafe) static var valueToInitialize = 42
177+
nonisolated(unsafe) static var countOfInitialization = 0
178+
static let value = LazyThreadLocal<Int>(initialize: {
180179
countOfInitialization += 1
181180
return valueToInitialize
182181
})
183-
static var value: Int
184182
}
185183
let executor = try await WebWorkerTaskExecutor(numberOfThreads: 1)
186184
XCTAssertEqual(Check.countOfInitialization, 0)
187-
XCTAssertEqual(Check.value, 42)
185+
XCTAssertEqual(Check.value.wrappedValue, 42)
188186
XCTAssertEqual(Check.countOfInitialization, 1)
189187

190188
Check.valueToInitialize = 100
191189

192190
let task = Task(executorPreference: executor) {
193191
XCTAssertEqual(Check.countOfInitialization, 1)
194-
XCTAssertEqual(Check.value, 100)
192+
XCTAssertEqual(Check.value.wrappedValue, 100)
195193
XCTAssertEqual(Check.countOfInitialization, 2)
196-
return Check.value
194+
return Check.value.wrappedValue
197195
}
198196
let result = await task.value
199197
XCTAssertEqual(result, 100)

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.