예제 #1
0
    void OpenJpegDecoder::Work()
    {
        while (ShouldRun())
        {
            WaitForRequests();
            
            DecodeRequestPtr request = GetNextRequest<DecodeRequest>();
            if (request)
            {
                // Wait if "too many" results already produced, to prevent slowing down the main thread with 
                // too many texture creations per frame
                Foundation::ThreadTaskManager* manager = GetThreadTaskManager();
                if (manager)
                {
                    for (;;)
                    {
                        uint results = manager->GetNumResults(GetTaskDescription());
                        if (results < decodes_per_frame_)
                            break;
                        if (!ShouldRun())
                            return;
                        boost::this_thread::sleep(boost::posix_time::milliseconds(20));
                    }
                }
                
                {
                    PROFILE(OpenJpegDecoder_Decode);
                    PerformDecode(request);
                }
            }

            RESETPROFILER
        }
    }
예제 #2
0
    void VorbisDecoder::Work()
    {
        while (ShouldRun())
        {
            WaitForRequests();
            
            VorbisDecodeRequestPtr request = GetNextRequest<VorbisDecodeRequest>();
            if (request)
            {
                {
                    PROFILE(VorbisDecoder_Decode);
                    PerformDecode(request);
                }
            }

            RESETPROFILER
        }
    }