@@ -724,23 +724,15 @@ public struct IORing: ~Copyable {
724724
725725 /// Attempts to prepare an IO request for submission to the kernel. Returns false if no space is available to enqueue the request
726726 @inlinable
727- public mutating func tryPrepare ( request: __owned Request) -> Bool {
727+ public mutating func prepare ( request: __owned Request) -> Bool {
728728 var raw : RawIORequest ? = request. makeRawRequest ( )
729729 return _tryWriteRequest (
730730 raw. take ( ) !, ring: & submissionRing, submissionQueueEntries: submissionQueueEntries)
731731 }
732732
733- /// Attempts to prepare an IO request for submission to the kernel. Blocks if needed until space becomes available to enqueue the request
734- @inlinable
735- public mutating func prepare( request: __owned Request) {
736- var raw : RawIORequest ? = request. makeRawRequest ( )
737- _writeRequest (
738- raw. take ( ) !, ring: & submissionRing, submissionQueueEntries: submissionQueueEntries)
739- }
740-
741733 /// Attempts to prepare a chain of linked IO requests for submission to the kernel. Returns false if not enough space is available to enqueue the request. If any linked operation fails, subsequent operations will be canceled. Linked operations always execute in order.
742734 @inlinable
743- mutating func tryPrepare ( linkedRequests: some BidirectionalCollection < Request > ) -> Bool {
735+ mutating func prepare ( linkedRequests: some BidirectionalCollection < Request > ) -> Bool {
744736 guard linkedRequests. count > 0 else {
745737 return true
746738 }
@@ -763,41 +755,20 @@ public struct IORing: ~Copyable {
763755 return true
764756 }
765757
766- /// Prepares a chain of linked IO requests for submission to the kernel. Blocks if needed until space becomes available to enqueue the requests. If any linked operation fails, subsequent operations will be canceled. Linked operations always execute in order.
767- @inlinable
768- mutating func prepare( linkedRequests: some BidirectionalCollection < Request > ) {
769- guard linkedRequests. count > 0 else {
770- return
771- }
772- let last = linkedRequests. last!
773- for req in linkedRequests. dropLast ( ) {
774- var raw = req. makeRawRequest ( )
775- raw. linkToNextRequest ( )
776- _writeRequest (
777- raw, ring: & submissionRing, submissionQueueEntries: submissionQueueEntries)
778- }
779- _writeRequest (
780- last. makeRawRequest ( ) , ring: & submissionRing,
781- submissionQueueEntries: submissionQueueEntries)
782- }
783-
784758 /// Prepares a sequence of requests for submission to the ring. Returns false if the submission queue doesn't have enough available space.
785759 @inlinable
786- public mutating func tryPrepare( linkedRequests: Request ... ) -> Bool {
787- tryPrepare ( linkedRequests: linkedRequests)
788- }
789-
790- /// Prepares a sequence of requests for submission to the ring. Blocks if the submission queue doesn't have enough available space.
791- @inlinable
792- public mutating func prepare( linkedRequests: Request ... ) {
760+ public mutating func prepare( linkedRequests: Request ... ) -> Bool {
793761 prepare ( linkedRequests: linkedRequests)
794762 }
795763
796- /// Prepares and submits a sequence of requests to the ring. Blocks if the submission queue doesn't have enough available space.
764+ /// Prepares and submits a sequence of requests to the ring. Returns false if the submission queue doesn't have enough available space.
797765 @inlinable
798- public mutating func submit( linkedRequests: Request ... ) throws ( Errno) {
799- prepare ( linkedRequests: linkedRequests)
766+ public mutating func submit( linkedRequests: Request ... ) throws ( Errno) -> Bool {
767+ if !prepare( linkedRequests: linkedRequests) {
768+ return false
769+ }
800770 try submitPreparedRequests ( )
771+ return true
801772 }
802773
803774 /// Describes which io_uring features are supported by the kernel this program is running on
0 commit comments