OSDN Git Service

post WM_NULL to attached threads on yamy exit to unmap mayu{32,64}.dll
[yamy/yamy.git] / engine.cpp
index f5dbd2c..fab96a8 100644 (file)
@@ -38,7 +38,7 @@ restart:
 \r
                        // erase dead thread\r
                        if (!m_detachedThreadIds.empty()) {\r
-                               for (DetachedThreadIds::iterator i = m_detachedThreadIds.begin();\r
+                               for (ThreadIds::iterator i = m_detachedThreadIds.begin();\r
                                                i != m_detachedThreadIds.end(); i ++) {\r
                                        FocusOfThreads::iterator j = m_focusOfThreads.find((*i));\r
                                        if (j != m_focusOfThreads.end()) {\r
@@ -1282,6 +1282,11 @@ void Engine::stop() {
 \r
        CHECK_TRUE( CloseHandle(m_readEvent) );\r
        m_readEvent = NULL;\r
+\r
+       for (ThreadIds::iterator i = m_attachedThreadIds.begin();\r
+                i != m_attachedThreadIds.end(); i++) {\r
+                PostThreadMessage(*i, WM_NULL, 0, 0);\r
+       }\r
 }\r
 \r
 \r
@@ -1478,7 +1483,7 @@ bool Engine::setFocus(HWND i_hwndFocus, DWORD i_threadId,
 \r
        // remove newly created thread's id from m_detachedThreadIds\r
        if (!m_detachedThreadIds.empty()) {\r
-               DetachedThreadIds::iterator i;\r
+               ThreadIds::iterator i;\r
                bool retry;\r
                do {\r
                        retry = false;\r
@@ -1580,10 +1585,20 @@ bool Engine::syncNotify() {
 }\r
 \r
 \r
+// thread attach notify\r
+bool Engine::threadAttachNotify(DWORD i_threadId) {\r
+       Acquire a(&m_cs);\r
+       m_attachedThreadIds.push_back(i_threadId);\r
+       return true;\r
+}\r
+\r
+\r
 // thread detach notify\r
 bool Engine::threadDetachNotify(DWORD i_threadId) {\r
        Acquire a(&m_cs);\r
        m_detachedThreadIds.push_back(i_threadId);\r
+       m_attachedThreadIds.erase(remove(m_attachedThreadIds.begin(), m_attachedThreadIds.end(), i_threadId),\r
+                                                         m_attachedThreadIds.end());\r
        return true;\r
 }\r
 \r