unique HosstConnection
Change-Id: I37425906eeecfc9a8a2c3a693efa248683ce3308
diff --git a/system/OpenglSystemCommon/HostConnection.h b/system/OpenglSystemCommon/HostConnection.h
index 2a4037f..d6a7940 100644
--- a/system/OpenglSystemCommon/HostConnection.h
+++ b/system/OpenglSystemCommon/HostConnection.h
@@ -23,6 +23,8 @@
#include "goldfish_dma.h"
#include <cutils/native_handle.h>
+#include <utils/threads.h>
+
#include <string>
class GLEncoder;
@@ -97,6 +99,10 @@
static HostConnection *get();
static HostConnection *getWithThreadInfo(EGLThreadInfo* tInfo);
static void exit();
+
+ static HostConnection *createUnique();
+ static void teardownUnique(HostConnection* con);
+
~HostConnection();
GLEncoder *glEncoder();
@@ -118,7 +124,14 @@
bool isGrallocOnly() const { return m_grallocOnly; }
+ void lock() const { m_lock.lock(); }
+ void unlock() const { m_lock.unlock(); }
+
private:
+ // If the connection failed, |conn| is deleted.
+ // Returns NULL if connection failed.
+ static HostConnection* connect(HostConnection* con);
+
HostConnection();
static gl_client_context_t *s_getGLContext();
static gl2_client_context_t *s_getGL2Context();
@@ -147,6 +160,7 @@
std::string m_glExtensions;
bool m_grallocOnly;
bool m_noHostError;
+ mutable android::Mutex m_lock;
};
#endif