-
Notifications
You must be signed in to change notification settings - Fork 107
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
Draft changes to the io_uring prototype #208
base: main
Are you sure you want to change the base?
Conversation
for some reason, the linker on my linux machine fails to link the tests otherwise. investigate / fix before merging.
@@ -1,18 +0,0 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This deletion seems probably wrong? Not sure where it came from
|
||
public struct AsyncFileDescriptor: ~Copyable { | ||
@usableFromInline var open: Bool = true | ||
@usableFromInline let fileSlot: IORingFileSlot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this should be a borrow of the file slot, but that's hard to express right now
mode, | ||
options: options, | ||
permissions: permissions, | ||
intoSlot: fileSlot.borrow() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a hack, this should also be an actual borrow
) | ||
} | ||
|
||
internal init(_ fileSlot: consuming IORingFileSlot, ring: ManagedIORing) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more "should be a borrow"
} | ||
|
||
@inlinable @inline(__always) | ||
public consuming func close(isolation actor: isolated (any Actor)? = #isolation) async throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to review the heavy use of isolation parameters at some point, as well as inlinability
self.isBorrow = isBorrow | ||
} | ||
|
||
func withResource() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
Sources/System/IORing.swift
Outdated
} | ||
|
||
//TODO: this is a workaround for lifetime issues and should be removed | ||
@usableFromInline func borrow() -> IOResource<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awful, but it unblocks me for now
let ringFlags: UInt32 | ||
let ringDescriptor: Int32 | ||
|
||
@usableFromInline let submissionMutex: Mutex<SQRing> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another dubiously inline thing
fatalError("failed to unregister files") | ||
} | ||
|
||
public func getFile() -> IORingFileSlot? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not clear to me that this is the interface we want, but need to think about it more
} | ||
|
||
public func submitAndWait(_ request: __owned IORequest, isolation actor: isolated (any Actor)? = #isolation) async -> IOCompletion { | ||
var consumeOnceWorkaround: IORequest? = request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working around "can't statically guarantee the closure will only be called once"
case nop // nothing here | ||
case openat( | ||
atDirectory: FileDescriptor, | ||
path: UnsafePointer<CChar>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path
should probably be a FilePath
?
No description provided.