mirror of
https://github.com/apple/swift-system
synced 2026-11-26 04:57:54 +00:00
Add a combined "submit and consume" operation
This commit is contained in:
1 parent
5e24673259
commit
49dd7977ca
1 file changed
+18
-2
@@ -450,10 +450,12 @@ public struct IORing: ~Copyable {
|
||||
ts: UInt64(UInt(bitPattern: tsPtr))
|
||||
)
|
||||
try _blockingConsumeCompletionGuts(
|
||||
minimumCount: minimumCount, maximumCount: UInt32.max, extraArgs: &args, consumer: consumer)
|
||||
minimumCount: minimumCount, maximumCount: UInt32.max, extraArgs: &args,
|
||||
consumer: consumer)
|
||||
}
|
||||
} else {
|
||||
try _blockingConsumeCompletionGuts(minimumCount: minimumCount, maximumCount: UInt32.max, consumer: consumer)
|
||||
try _blockingConsumeCompletionGuts(
|
||||
minimumCount: minimumCount, maximumCount: UInt32.max, consumer: consumer)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,6 +592,20 @@ public struct IORing: ~Copyable {
|
||||
try _submitRequests(ring: submissionRing, ringDescriptor: ringDescriptor)
|
||||
}
|
||||
|
||||
public func submitPreparedRequestsAndConsumeCompletions(
|
||||
minimumCount: UInt32 = 1,
|
||||
timeout: Duration? = nil,
|
||||
consumer: (IOCompletion?, IORingError?, Bool) throws -> Void
|
||||
) throws {
|
||||
//TODO: optimize this to one uring_enter
|
||||
try submitPreparedRequests()
|
||||
try blockingConsumeCompletions(
|
||||
minimumCount: minimumCount,
|
||||
timeout: timeout,
|
||||
consumer: consumer
|
||||
)
|
||||
}
|
||||
|
||||
public mutating func prepare(request: __owned IORequest) -> Bool {
|
||||
var raw: RawIORequest? = request.makeRawRequest()
|
||||
return _writeRequest(
|
||||
|
||||
Reference in new issue
Block a user