다음을 통해 공유


IThreadPoolConfig::GetSize

스레드 풀에서 가져오도록이 메서드를 호출 합니다.

STDMETHOD(GetSize)(
   int * pnNumThreads 
);

매개 변수

  • pnNumThreads
    [out] 주소는 성공 하면 스레드 풀에서 받는 변수입니다.

반환 값

실패 HRESULT 오류 또는 성공한 경우 S_OK를 반환합니다.

예제

HRESULT DoPoolOperations(IThreadPoolConfig* pPool, int nSize)
{
    int nCurrSize = 0;
    HRESULT hr = pPool->GetSize(&nCurrSize);
    if (SUCCEEDED(hr))
    {
        printf_s("Current pool size: %d\n", nCurrSize);
        hr = pPool->SetSize(nSize);
        if (SUCCEEDED(hr))
        {
            printf_s("New pool size : %d\n", nSize);
            DWORD dwTimeout = 0;
            hr = pPool->GetTimeout(&dwTimeout);
            if (SUCCEEDED(hr))
            {
                printf_s("Current pool timeout: %u\n", dwTimeout);
                // Increase timeout by 10 seconds.
                dwTimeout += 10 * 1000;
                hr = pPool->SetTimeout(dwTimeout);
                if (SUCCEEDED(hr))
                {
                    printf_s("New pool timeout: %u\n", dwTimeout);
                }
                else
                {
                    printf_s("Failed to set pool timeout: 0x%08X\n", hr);
                }
            }
            else
            {
                printf_s("Failed to get pool timeout: 0x%08X\n", hr);
            }
        }
        else
        {
            printf_s("Failed to resize pool: 0x%08X\n", hr);
        }
    }
    else
    {
        printf_s("Failed to get pool size: 0x%08x\n", hr);
    }

    return hr;
}

요구 사항

헤더: atlutil.h

참고 항목

참조

IThreadPoolConfig 인터페이스

IThreadPoolConfig::SetSize