comparison data/fileio/FileReadThread.cpp @ 689:573d45e9487b

Merge from debug-output branch
author Chris Cannam
date Tue, 14 Jun 2011 14:47:59 +0100
parents 06f13a3b9e9e
children 1424aa29ae95
comparison
equal deleted inserted replaced
688:be43b2fe68e8 689:573d45e9487b
45 } 45 }
46 46
47 notifyCancelled(); 47 notifyCancelled();
48 48
49 #ifdef DEBUG_FILE_READ_THREAD 49 #ifdef DEBUG_FILE_READ_THREAD
50 std::cerr << "FileReadThread::run() exiting" << std::endl; 50 DEBUG << "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 std::cerr << "FileReadThread::finish()" << std::endl; 58 DEBUG << "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 std::cerr << "FileReadThread::finish() exiting" << std::endl; 76 DEBUG << "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 std::cerr << "FileReadThread::cancel(" << token << ") waking condition" << std::endl; 116 DEBUG << "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 std::cerr << "FileReadThread::process: reading " << request.start << ", " << request.size << " on " << request.fd << std::endl; 219 DEBUG << "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 std::cerr << "FileReadThread::process: done, marking as ready (success = " << m_readyRequests[token].successful << ")" << std::endl; 292 DEBUG << "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 std::cerr << "FileReadThread::process: exiting" << std::endl; 297 DEBUG << "FileReadThread::process: exiting" << endl;
298 } else { 298 } else {
299 std::cerr << "FileReadThread::process: request disappeared" << std::endl; 299 DEBUG << "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 std::cerr << "FileReadThread::notifyCancelled: token " << token << std::endl; 315 DEBUG << "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 }