2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "resource-collector.h"
19 #include "tizen-platform-abstraction.h"
20 #include <dali/integration-api/debug.h>
29 using namespace Dali::Integration;
31 ResourceCollector::ResourceCollector() :
32 mGrandTotalCompletions(0),
33 mGrandTotalNotifications(0)
37 ResourceCollector::~ResourceCollector() {}
39 void ResourceCollector::LoadResponse( Dali::Integration::ResourceId id, Dali::Integration::ResourceTypeId type, Dali::Integration::ResourcePointer resource, Dali::Integration::LoadStatus status )
41 ++mGrandTotalNotifications;
42 if( status == RESOURCE_COMPLETELY_LOADED )
44 DALI_ASSERT_DEBUG( mCompletionCounts.find(id) == mCompletionCounts.end() && "A resource can only complete once." );
45 mCompletionStatuses[id] = true;
46 ++mCompletionCounts[id];
48 mCompletionSequence.push_back( id );
49 ++mGrandTotalCompletions;
53 void ResourceCollector::LoadFailed( Dali::Integration::ResourceId id, Dali::Integration::ResourceFailure failure )
55 mCompletionStatuses[id] = false;
57 mCompletionSequence.push_back( id );
58 ++mGrandTotalCompletions;
59 ++mGrandTotalNotifications;
62 void PollForNotification( ResourceCollector& collector, Integration::PlatformAbstraction& abstraction, const unsigned maxPolls )
64 // Poll for at least one completed or partially completed load:
65 const unsigned outstandingNotifications = collector.mGrandTotalNotifications;
66 for( unsigned poll = 0; poll < maxPolls; ++poll )
68 abstraction.GetResources( collector );
69 if( collector.mGrandTotalNotifications > outstandingNotifications )
73 usleep( 3 ); //< Wait 3 microseconds each time around.
77 } /* namespace Platform */
78 } /* namespace Internal */
79 } /* namespace Dali */