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

Draft changes to the io_uring prototype #208

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft

Conversation

Catfish-Man
Copy link
Member

No description provided.

@Catfish-Man Catfish-Man self-assigned this Oct 29, 2024
@@ -1,18 +0,0 @@
/*
Copy link
Member Author

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
Copy link
Member Author

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()
Copy link
Member Author

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) {
Copy link
Member Author

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 {
Copy link
Member Author

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() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

}

//TODO: this is a workaround for lifetime issues and should be removed
@usableFromInline func borrow() -> IOResource<T> {
Copy link
Member Author

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>
Copy link
Member Author

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? {
Copy link
Member Author

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
Copy link
Member Author

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>,
Copy link
Member Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants