title: io_uring: io_uring_wait_cqe_nr, io_uring_peek_batch_cqe
body: <p>I want to experiment io_uring on the github project:
  <a href="https://github.com/alexhultman/io_uring_epoll_benchmark" rel="nofollow noreferrer">https://github.com/alexhultman/io_uring_epoll_benchmark</a></p>
  <p>referrence: <a href="https://unixism.net/loti/ref-liburing/completion.html" rel="nofollow noreferrer">https://unixism.net/loti/ref-liburing/completion.html</a></p>
  <p>however I stumbled upon 2 functions:</p>
  <ol>
  <li><p>unsigned io_uring_peek_batch_cqe(struct io_uring *ring, struct io_uring_cqe **cqes, unsigned count)</p>
  </li>
  <li><p>int io_uring_wait_cqe_nr(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, unsigned wait_nr)</p>
  </li>
  </ol>
  <p>I understand that the first functions will fills in an array of I/O completions up to count to the cqes
  and will return regardless of how many cqes completions</p>
  <p>However the second functions only fills in one I/O completions to the cqes even I wait for wait_nr completions, why is this so, if it wait for specific number of cqes completions, why i didn't fill in the array of I/O like the first function did?</p>
  <p>like example i create:
  #define MAX_BATCH 2000</p>
  <p>struct io_uring_cqe **cqes = malloc(sizeof(struct io_uring_cqe *) * MAX_BATCH);</p>
  <p>if I run on the first function, i could access cqes[i] i = (0 to completions)</p>
  <p>if I run on the second function, I can only access cqes[i] i = 0</p>
  <p>I need to understand why the second function never update the array of cqes like the first function did</p>