@@ -196,7 +196,7 @@ class Crystal::System::IoUring
196196 end
197197
198198 def sq_need_wakeup ? : Bool
199- sq_flags = Atomic ::Ops .load(@sq_flags , :acquire , volatile: true )
199+ sq_flags = Atomic ::Ops .load(@sq_flags , :monotonic , volatile: true )
200200 (sq_flags & LibC ::IORING_SQ_NEED_WAKEUP ) == LibC ::IORING_SQ_NEED_WAKEUP
201201 end
202202
@@ -216,12 +216,13 @@ class Crystal::System::IoUring
216216 # Makes sure there is at least *count* SQE available in the SQ ring so we can
217217 # submit a chain of SQE at once. Submits pending SQE and waits if needed.
218218 def reserve (count : Int32 ) : Nil
219- raise ArgumentError .new(" Can't reserve more SQE than available in the SQ ring" ) if count > @sq_entries .value
219+ if count > @sq_entries .value
220+ raise ArgumentError .new(" Can't reserve more SQE than available in the SQ ring" )
221+ end
220222
221223 loop do
222- tail = @sq_tail # Atomic::Ops.load(@sq_ktail, :monotonic, volatile: true)
223224 head = Atomic ::Ops .load(@sq_khead , :monotonic , volatile: true )
224- size = tail &- head
225+ size = @sq_tail &- head
225226
226227 if (@sq_entries .value - size) >= count
227228 break
@@ -253,7 +254,7 @@ class Crystal::System::IoUring
253254 # Blocks until at least one SQE becomes available when *wait* is true.
254255 def submit (flags : UInt32 = 0 _u32 , wait : Bool = false )
255256 # make new tail and previous writes visible to the kernel threads
256- Atomic ::Ops .store(@sq_ktail , @sq_tail , :release , volatile: true )
257+ Atomic ::Ops .store(@sq_ktail , @sq_tail , :sequentially_consistent , volatile: true )
257258
258259 if sq_poll?
259260 if wait
@@ -301,8 +302,8 @@ class Crystal::System::IoUring
301302 #
302303 # WARNING: the yielded pointer is only valid for the duration of the block!
303304 def each_completed (& : LibC ::IoUringCqe * - > ) : Nil
304- head = Atomic ::Ops .load(@cq_khead , :monotonic , volatile: true )
305- tail = Atomic ::Ops .load(@cq_ktail , :acquire , volatile: true )
305+ head = Atomic ::Ops .load(@cq_khead , :acquire , volatile: true )
306+ tail = Atomic ::Ops .load(@cq_ktail , :monotonic , volatile: true )
306307 return if head == tail
307308
308309 until head == tail
0 commit comments