+/* dequeue completion entrees directly (no separate completion thread) */
+static int fio_windowsaio_getevents_nothread(struct thread_data *td, unsigned int min,
+ unsigned int max, const struct timespec *t)
+{
+ struct windowsaio_data *wd = td->io_ops_data;
+ unsigned int dequeued = 0;
+ struct io_u *io_u;
+ DWORD start_count = 0;
+ DWORD end_count = 0;
+ DWORD mswait = 250;
+ struct fio_overlapped *fov;
+
+ if (t != NULL) {
+ mswait = (t->tv_sec * 1000) + (t->tv_nsec / 1000000);
+ start_count = GetTickCount();
+ end_count = start_count + (t->tv_sec * 1000) + (t->tv_nsec / 1000000);
+ }
+
+ do {
+ BOOL ret;
+ OVERLAPPED *ovl;
+
+ ULONG entries = min(16, max-dequeued);
+ OVERLAPPED_ENTRY oe[16];
+ ret = GetQueuedCompletionStatusEx(wd->iocp, oe, 16, &entries, mswait, 0);
+ if (ret && entries) {
+ int entry_num;
+
+ for (entry_num=0; entry_num<entries; entry_num++) {
+ ovl = oe[entry_num].lpOverlapped;
+ fov = CONTAINING_RECORD(ovl, struct fio_overlapped, o);
+ io_u = fov->io_u;
+
+ if (ovl->Internal == ERROR_SUCCESS) {
+ io_u->resid = io_u->xfer_buflen - ovl->InternalHigh;
+ io_u->error = 0;
+ } else {
+ io_u->resid = io_u->xfer_buflen;
+ io_u->error = win_to_posix_error(GetLastError());
+ }
+
+ fov->io_complete = FALSE;
+ wd->aio_events[dequeued] = io_u;
+ dequeued++;
+ }
+ }
+
+ if (dequeued >= min ||
+ (t != NULL && timeout_expired(start_count, end_count)))
+ break;
+ } while (1);
+ return dequeued;
+}
+
+/* dequeue completion entrees creates by separate IoCompletionRoutine thread */
+static int fio_windowaio_getevents_thread(struct thread_data *td, unsigned int min,
+ unsigned int max, const struct timespec *t)