Dali 3D User Interface Engine
resource-collector.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 
18 #include "resource-collector.h"
21 #include <unistd.h>
22 
23 namespace Dali
24 {
25 namespace Internal
26 {
27 namespace Platform
28 {
29 using namespace Dali::Integration;
30 
32  mGrandTotalCompletions(0),
33  mGrandTotalNotifications(0)
34 {
35 }
36 
38 
40 {
42  if( status == RESOURCE_COMPLETELY_LOADED )
43  {
44  DALI_ASSERT_DEBUG( mCompletionCounts.find(id) == mCompletionCounts.end() && "A resource can only complete once." );
45  mCompletionStatuses[id] = true;
46  ++mCompletionCounts[id];
47  ++mSuccessCounts[id];
48  mCompletionSequence.push_back( id );
50  }
51 }
52 
54 {
55  mCompletionStatuses[id] = false;
56  ++mFailureCounts[id];
57  mCompletionSequence.push_back( id );
60 }
61 
62 void PollForNotification( ResourceCollector& collector, Integration::PlatformAbstraction& abstraction, const unsigned maxPolls )
63 {
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 )
67  {
68  abstraction.GetResources( collector );
69  if( collector.mGrandTotalNotifications > outstandingNotifications )
70  {
71  break;
72  }
73  usleep( 3 ); //< Wait 3 microseconds each time around.
74  }
75 }
76 
77 } /* namespace Platform */
78 } /* namespace Internal */
79 } /* namespace Dali */
Dali Docs Home
Read more about Dali