Mercurial > hg > svcore
comparison base/StorageAdviser.cpp @ 843:e802e550a1f2
Drop std:: from cout, cerr, endl -- pull these in through Debug.h
author | Chris Cannam |
---|---|
date | Tue, 26 Nov 2013 13:35:08 +0000 |
parents | 1424aa29ae95 |
children | cc27f35aa75c |
comparison
equal
deleted
inserted
replaced
842:23d3a6eca5c3 | 843:e802e550a1f2 |
---|---|
47 | 47 |
48 QString path; | 48 QString path; |
49 try { | 49 try { |
50 path = TempDirectory::getInstance()->getPath(); | 50 path = TempDirectory::getInstance()->getPath(); |
51 } catch (std::exception e) { | 51 } catch (std::exception e) { |
52 std::cerr << "StorageAdviser::recommend: ERROR: Failed to get temporary directory path: " << e.what() << std::endl; | 52 cerr << "StorageAdviser::recommend: ERROR: Failed to get temporary directory path: " << e.what() << endl; |
53 return Recommendation(UseMemory | ConserveSpace); | 53 return Recommendation(UseMemory | ConserveSpace); |
54 } | 54 } |
55 int discFree = GetDiscSpaceMBAvailable(path.toLocal8Bit()); | 55 int discFree = GetDiscSpaceMBAvailable(path.toLocal8Bit()); |
56 int memoryFree, memoryTotal; | 56 int memoryFree, memoryTotal; |
57 GetRealMemoryMBAvailable(memoryFree, memoryTotal); | 57 GetRealMemoryMBAvailable(memoryFree, memoryTotal); |
67 } else if (memoryFree > 0) { // can also be -1 for unknown | 67 } else if (memoryFree > 0) { // can also be -1 for unknown |
68 memoryFree = 0; | 68 memoryFree = 0; |
69 } | 69 } |
70 | 70 |
71 #ifdef DEBUG_STORAGE_ADVISER | 71 #ifdef DEBUG_STORAGE_ADVISER |
72 std::cerr << "Disc space: " << discFree << ", memory free: " << memoryFree << ", memory total: " << memoryTotal << ", min " << minimumSize << ", max " << maximumSize << std::endl; | 72 cerr << "Disc space: " << discFree << ", memory free: " << memoryFree << ", memory total: " << memoryTotal << ", min " << minimumSize << ", max " << maximumSize << endl; |
73 #endif | 73 #endif |
74 | 74 |
75 //!!! We have a potentially serious problem here if multiple | 75 //!!! We have a potentially serious problem here if multiple |
76 //recommendations are made in advance of any of the resulting | 76 //recommendations are made in advance of any of the resulting |
77 //allocations, as the allocations that have been recommended for | 77 //allocations, as the allocations that have been recommended for |
104 else if (maxmb > (discFree / 4)) discStatus = Marginal; | 104 else if (maxmb > (discFree / 4)) discStatus = Marginal; |
105 else if (minmb > (discFree / 10)) discStatus = Marginal; | 105 else if (minmb > (discFree / 10)) discStatus = Marginal; |
106 else discStatus = Sufficient; | 106 else discStatus = Sufficient; |
107 | 107 |
108 #ifdef DEBUG_STORAGE_ADVISER | 108 #ifdef DEBUG_STORAGE_ADVISER |
109 std::cerr << "Memory status: " << memoryStatus << ", disc status " | 109 cerr << "Memory status: " << memoryStatus << ", disc status " |
110 << discStatus << std::endl; | 110 << discStatus << endl; |
111 #endif | 111 #endif |
112 | 112 |
113 int recommendation = NoRecommendation; | 113 int recommendation = NoRecommendation; |
114 | 114 |
115 if (memoryStatus == Insufficient || memoryStatus == Unknown) { | 115 if (memoryStatus == Insufficient || memoryStatus == Unknown) { |
187 void | 187 void |
188 StorageAdviser::notifyPlannedAllocation(AllocationArea area, int size) | 188 StorageAdviser::notifyPlannedAllocation(AllocationArea area, int size) |
189 { | 189 { |
190 if (area == MemoryAllocation) m_memoryPlanned += size; | 190 if (area == MemoryAllocation) m_memoryPlanned += size; |
191 else if (area == DiscAllocation) m_discPlanned += size; | 191 else if (area == DiscAllocation) m_discPlanned += size; |
192 // std::cerr << "storage planned up: memory: " << m_memoryPlanned << ", disc " | 192 // cerr << "storage planned up: memory: " << m_memoryPlanned << ", disc " |
193 // << m_discPlanned << std::endl; | 193 // << m_discPlanned << endl; |
194 } | 194 } |
195 | 195 |
196 void | 196 void |
197 StorageAdviser::notifyDoneAllocation(AllocationArea area, int size) | 197 StorageAdviser::notifyDoneAllocation(AllocationArea area, int size) |
198 { | 198 { |
201 else m_memoryPlanned = 0; | 201 else m_memoryPlanned = 0; |
202 } else if (area == DiscAllocation) { | 202 } else if (area == DiscAllocation) { |
203 if (m_discPlanned > size) m_discPlanned -= size; | 203 if (m_discPlanned > size) m_discPlanned -= size; |
204 else m_discPlanned = 0; | 204 else m_discPlanned = 0; |
205 } | 205 } |
206 // std::cerr << "storage planned down: memory: " << m_memoryPlanned << ", disc " | 206 // cerr << "storage planned down: memory: " << m_memoryPlanned << ", disc " |
207 // << m_discPlanned << std::endl; | 207 // << m_discPlanned << endl; |
208 } | 208 } |
209 | 209 |
210 void | 210 void |
211 StorageAdviser::setFixedRecommendation(Recommendation recommendation) | 211 StorageAdviser::setFixedRecommendation(Recommendation recommendation) |
212 { | 212 { |