Skip to content

Commit

Permalink
support drain
Browse files Browse the repository at this point in the history
  • Loading branch information
Iceber committed Oct 21, 2020
1 parent 6e053cc commit 43444f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions iouring.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type IOURing struct {
cq *CompletionQueue

async bool
drain bool
Flags uint32
Features uint32

Expand Down Expand Up @@ -173,6 +174,9 @@ func (iour *IOURing) doRequest(sqe *iouring_syscall.SubmissionQueueEntry, reques
if iour.async {
sqe.SetFlags(iouring_syscall.IOSQE_FLAGS_ASYNC)
}
if iour.drain {
sqe.SetFlags(iouring_syscall.IOSQE_FLAGS_IO_DRAIN)
}
return userData, nil
}

Expand Down
7 changes: 7 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,10 @@ func WithDisableRing() IOURingOption {
iour.params.Flags |= iouring_syscall.IORING_SETUP_R_DISABLED
}
}

// WithDrain every SQE will not be started before previously submitted SQEs have completed
func WithDrain() IOURingOption {
return func(iour *IOURing) {
iour.drain = true
}
}

0 comments on commit 43444f1

Please sign in to comment.