| 85 | |
| 86 | |
| 87 | CWelsThreadPool* CWelsThreadPool::AddReference() { |
| 88 | CWelsAutoLock cLock (GetInitLock()); |
| 89 | if (m_pThreadPoolSelf == NULL) { |
| 90 | m_pThreadPoolSelf = new CWelsThreadPool(); |
| 91 | if (!m_pThreadPoolSelf) { |
| 92 | return NULL; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | if (m_iRefCount == 0) { |
| 97 | if (WELS_THREAD_ERROR_OK != m_pThreadPoolSelf->Init()) { |
| 98 | m_pThreadPoolSelf->Uninit(); |
| 99 | delete m_pThreadPoolSelf; |
| 100 | m_pThreadPoolSelf = NULL; |
| 101 | return NULL; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | ////fprintf(stdout, "m_iRefCount=%d, iMaxThreadNum=%d\n", m_iRefCount, m_iMaxThreadNum); |
| 106 | |
| 107 | ++ m_iRefCount; |
| 108 | //fprintf(stdout, "m_iRefCount2=%d\n", m_iRefCount); |
| 109 | return m_pThreadPoolSelf; |
| 110 | } |
| 111 | |
| 112 | void CWelsThreadPool::RemoveInstance() { |
| 113 | CWelsAutoLock cLock (GetInitLock()); |