mirror of
https://github.com/apple/swift-async-algorithms
synced 2026-11-28 04:54:20 +00:00
Get nearly everything up and rolling for linux (#85)
* Get nearly everything up and rolling for linux * Alter validation diagrams for an internal function to expect failures
This commit is contained in:
1 parent
5ac8bb4d07
commit
3447a342ac
9 files changed
+103
-90
No files matched your search
@@ -13,6 +13,11 @@ public struct SourceLocation: Sendable, CustomStringConvertible {
|
||||
public var file: StaticString
|
||||
public var line: UInt
|
||||
|
||||
public init(file: StaticString, line: UInt) {
|
||||
self.file = file
|
||||
self.line = line
|
||||
}
|
||||
|
||||
public var description: String {
|
||||
return "\(file):\(line)"
|
||||
}
|
||||
|
||||
@@ -19,17 +19,32 @@ import _CAsyncSequenceValidationSupport
|
||||
#error("TODO: Port TaskDriver threading to windows")
|
||||
#endif
|
||||
|
||||
#if canImport(Darwin)
|
||||
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
|
||||
func start_thread(_ raw: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer? {
|
||||
Unmanaged<TaskDriver>.fromOpaque(raw).takeRetainedValue().run()
|
||||
return nil
|
||||
}
|
||||
#elseif canImport(Glibc)
|
||||
func start_thread(_ raw: UnsafeMutableRawPointer?) -> UnsafeMutableRawPointer? {
|
||||
Unmanaged<TaskDriver>.fromOpaque(raw!).takeRetainedValue().run()
|
||||
return nil
|
||||
}
|
||||
#elseif canImport(WinSDK)
|
||||
#error("TODO: Port TaskDriver threading to windows")
|
||||
#endif
|
||||
|
||||
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
|
||||
final class TaskDriver {
|
||||
let work: (TaskDriver) -> Void
|
||||
let queue: WorkQueue
|
||||
#if canImport(Darwin)
|
||||
var thread: pthread_t?
|
||||
#elseif canImport(Glibc)
|
||||
var thread = pthread_t()
|
||||
#elseif canImport(WinSDK)
|
||||
#error("TODO: Port TaskDriver threading to windows")
|
||||
#endif
|
||||
|
||||
init(queue: WorkQueue, _ work: @escaping (TaskDriver) -> Void) {
|
||||
self.queue = queue
|
||||
@@ -42,12 +57,20 @@ final class TaskDriver {
|
||||
}
|
||||
|
||||
func run() {
|
||||
#if canImport(Darwin)
|
||||
pthread_setname_np("Validation Diagram Clock Driver")
|
||||
#endif
|
||||
work(self)
|
||||
}
|
||||
|
||||
func join() {
|
||||
#if canImport(Darwin)
|
||||
pthread_join(thread!, nil)
|
||||
#elseif canImport(Glibc)
|
||||
pthread_join(thread, nil)
|
||||
#elseif canImport(WinSDK)
|
||||
#error("TODO: Port TaskDriver threading to windows")
|
||||
#endif
|
||||
}
|
||||
|
||||
func enqueue(_ job: JobRef) {
|
||||
|
||||
Reference in new issue
Block a user