std::shared_ptr wait()

in src/posix_aio.cc [225:263]


			std::shared_ptr<IAsyncIop> wait(int group_id) {
				if (!started) assert(!"IOManager not started!");

				// suspending
				suspend_mutex.lock();
				auto vec = suspend_vecs[group_id];
				suspend_mutex.unlock();

				int err = aio_suspend((const aiocb * const *)&((*vec)[0]), (int)vec->size(), NULL);

				if (err) {
					perror("IOManager error! aio_suspend");
					exit(1);
				}

				// will throw error if not in map i guess
				for (auto it = vec->cbegin(); it != vec->cend(); ) {

					if(aio_error(*it) == EINPROGRESS) {
						++it;
						continue;
					}

					// get flight id
					unsigned int flight_id = (unsigned int)((*it)->aio_sigevent.sigev_value.sival_int);
					// erase cb from vector
					vec->erase(it);

					suspend_in_flight_mutex.lock();
					auto iop = suspend_in_flight[flight_id];
					// remove from the in flight list
					suspend_in_flight.erase(flight_id);
					suspend_in_flight_mutex.unlock();
					return iop;
				}

				fprintf(stderr, "IOManager error! No completed iops\n");
				exit(1);
			}