comparison data/fileio/FileReadThread.cpp @ 690:1424aa29ae95

Seems to be a bad idea to use plain DEBUG symbol on OS/X (system wants it)
author Chris Cannam
date Tue, 14 Jun 2011 15:26:52 +0100
parents 06f13a3b9e9e
children e802e550a1f2
comparison
equal deleted inserted replaced
689:573d45e9487b 690:1424aa29ae95
45 } 45 }
46 46
47 notifyCancelled(); 47 notifyCancelled();
48 48
49 #ifdef DEBUG_FILE_READ_THREAD 49 #ifdef DEBUG_FILE_READ_THREAD
50 DEBUG << "FileReadThread::run() exiting" << endl; 50 SVDEBUG << "FileReadThread::run() exiting" << endl;
51 #endif 51 #endif
52 } 52 }
53 53
54 void 54 void
55 FileReadThread::finish() 55 FileReadThread::finish()
56 { 56 {
57 #ifdef DEBUG_FILE_READ_THREAD 57 #ifdef DEBUG_FILE_READ_THREAD
58 DEBUG << "FileReadThread::finish()" << endl; 58 SVDEBUG << "FileReadThread::finish()" << endl;
59 #endif 59 #endif
60 60
61 { 61 {
62 MutexLocker locker(&m_mutex, "FileReadThread::finish::m_mutex"); 62 MutexLocker locker(&m_mutex, "FileReadThread::finish::m_mutex");
63 63
71 } 71 }
72 72
73 m_condition.wakeAll(); 73 m_condition.wakeAll();
74 74
75 #ifdef DEBUG_FILE_READ_THREAD 75 #ifdef DEBUG_FILE_READ_THREAD
76 DEBUG << "FileReadThread::finish() exiting" << endl; 76 SVDEBUG << "FileReadThread::finish() exiting" << endl;
77 #endif 77 #endif
78 } 78 }
79 79
80 int 80 int
81 FileReadThread::request(const Request &request) 81 FileReadThread::request(const Request &request)
111 std::cerr << "WARNING: FileReadThread::cancel: token " << token << " not found" << std::endl; 111 std::cerr << "WARNING: FileReadThread::cancel: token " << token << " not found" << std::endl;
112 } 112 }
113 } 113 }
114 114
115 #ifdef DEBUG_FILE_READ_THREAD 115 #ifdef DEBUG_FILE_READ_THREAD
116 DEBUG << "FileReadThread::cancel(" << token << ") waking condition" << endl; 116 SVDEBUG << "FileReadThread::cancel(" << token << ") waking condition" << endl;
117 #endif 117 #endif
118 118
119 m_condition.wakeAll(); 119 m_condition.wakeAll();
120 } 120 }
121 121
214 Request request = m_queue.begin()->second; 214 Request request = m_queue.begin()->second;
215 215
216 m_mutex.unlock(); 216 m_mutex.unlock();
217 217
218 #ifdef DEBUG_FILE_READ_THREAD 218 #ifdef DEBUG_FILE_READ_THREAD
219 DEBUG << "FileReadThread::process: reading " << request.start << ", " << request.size << " on " << request.fd << endl; 219 SVDEBUG << "FileReadThread::process: reading " << request.start << ", " << request.size << " on " << request.fd << endl;
220 #endif 220 #endif
221 221
222 bool successful = false; 222 bool successful = false;
223 bool seekFailed = false; 223 bool seekFailed = false;
224 ssize_t r = 0; 224 ssize_t r = 0;
287 287
288 if (m_queue.find(token) != m_queue.end() && !m_exiting) { 288 if (m_queue.find(token) != m_queue.end() && !m_exiting) {
289 m_queue.erase(token); 289 m_queue.erase(token);
290 m_readyRequests[token] = request; 290 m_readyRequests[token] = request;
291 #ifdef DEBUG_FILE_READ_THREAD 291 #ifdef DEBUG_FILE_READ_THREAD
292 DEBUG << "FileReadThread::process: done, marking as ready (success = " << m_readyRequests[token].successful << ")" << endl; 292 SVDEBUG << "FileReadThread::process: done, marking as ready (success = " << m_readyRequests[token].successful << ")" << endl;
293 #endif 293 #endif
294 } else { 294 } else {
295 #ifdef DEBUG_FILE_READ_THREAD 295 #ifdef DEBUG_FILE_READ_THREAD
296 if (m_exiting) { 296 if (m_exiting) {
297 DEBUG << "FileReadThread::process: exiting" << endl; 297 SVDEBUG << "FileReadThread::process: exiting" << endl;
298 } else { 298 } else {
299 DEBUG << "FileReadThread::process: request disappeared" << endl; 299 SVDEBUG << "FileReadThread::process: request disappeared" << endl;
300 } 300 }
301 #endif 301 #endif
302 } 302 }
303 } 303 }
304 304
310 while (!m_newlyCancelled.empty()) { 310 while (!m_newlyCancelled.empty()) {
311 311
312 int token = *m_newlyCancelled.begin(); 312 int token = *m_newlyCancelled.begin();
313 313
314 #ifdef DEBUG_FILE_READ_THREAD 314 #ifdef DEBUG_FILE_READ_THREAD
315 DEBUG << "FileReadThread::notifyCancelled: token " << token << endl; 315 SVDEBUG << "FileReadThread::notifyCancelled: token " << token << endl;
316 #endif 316 #endif
317 317
318 m_newlyCancelled.erase(token); 318 m_newlyCancelled.erase(token);
319 } 319 }
320 } 320 }