github.com/ii64/gouring@v0.4.1/uring.go (about) 1 package gouring 2 3 func New(entries uint32, flags uint32) (*IoUring, error) { 4 ring := &IoUring{} 5 p := new(IoUringParams) 6 p.Flags = flags 7 err := io_uring_queue_init_params(entries, ring, p) 8 if err != nil { 9 return nil, err 10 } 11 return ring, nil 12 } 13 14 func NewWithParams(entries uint32, params *IoUringParams) (*IoUring, error) { 15 ring := &IoUring{} 16 if params == nil { 17 params = new(IoUringParams) 18 } 19 err := io_uring_queue_init_params(entries, ring, params) 20 if err != nil { 21 return nil, err 22 } 23 return ring, nil 24 } 25 26 func (h *IoUring) Close() { 27 h.io_uring_queue_exit() 28 } 29 30 func (h *IoUring) GetSqe() *IoUringSqe { 31 return h.io_uring_get_sqe() 32 } 33 34 func (h *IoUring) WaitCqe(cqePtr **IoUringCqe) error { 35 return h.io_uring_wait_cqe(cqePtr) 36 } 37 38 func (h *IoUring) SeenCqe(cqe *IoUringCqe) { 39 h.io_uring_cqe_seen(cqe) 40 } 41 42 func (h *IoUring) Submit() (int, error) { 43 return h.io_uringn_submit() 44 } 45 46 func (h *IoUring) SubmitAndWait(waitNr uint32) (int, error) { 47 return h.io_uring_submit_and_wait(waitNr) 48 }