int submit()

in src/posix_aio.cc [182:223]


			int submit(int group_id) {
				if (!started) assert(!"IOManager not started!");

				int ret;
				// get the group queue
				group_queues_mutex.lock();
				auto queue = group_queues[group_id];
				group_queues_mutex.unlock();
				// get the suspend vector
				suspend_mutex.lock();
				auto suspend_vec = suspend_vecs[group_id];
				suspend_mutex.unlock();

				while (queue->size()) {

					// consume the op from the back of the vector
					auto a = queue->back();
					queue->pop_back();

					// start op
					if (a->type == IAsyncIop::Type::READ) {
						ret = aio_read(&(a->cb));
					} else {
						ret = aio_write(&(a->cb));
					}
					if (ret) return ret;

					// push aiocb to vector
					suspend_vec->push_back(&(a->cb));

					// get a valid next flight id, add to struct, add to in flight map
					suspend_in_flight_mutex.lock();
					while(suspend_in_flight.count(next_flight_id)) ++next_flight_id;

					a->cb.aio_sigevent.sigev_value.sival_int = (int)next_flight_id;
					suspend_in_flight[next_flight_id] = a;
					++next_flight_id;
					suspend_in_flight_mutex.unlock();
				}

				return 0;
			}