Switch to a thread pool for aio operations
Creating a thread for each operation was
slightly wasteful. This also makes traces
easier to read.
Test: Transfer files, view traces
Bug: 76154677
Change-Id: I6028f113b9e5a84f01fb020a209a4dccadfdece4
diff --git a/media/mtp/PosixAsyncIO.h b/media/mtp/PosixAsyncIO.h
index 590aaef..2bb5735 100644
--- a/media/mtp/PosixAsyncIO.h
+++ b/media/mtp/PosixAsyncIO.h
@@ -17,10 +17,11 @@
#ifndef _POSIXASYNCIO_H
#define _POSIXASYNCIO_H
+#include <condition_variable>
+#include <mutex>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <time.h>
-#include <thread>
#include <unistd.h>
/**
@@ -35,10 +36,15 @@
size_t aio_nbytes;
// Used internally
- std::thread thread;
+ bool read;
+ bool queued;
ssize_t ret;
int error;
+ std::mutex lock;
+ std::condition_variable cv;
+
+ aiocb();
~aiocb();
};