49 #ifdef DEBUG_FILE_READ_THREAD 50 SVDEBUG <<
"FileReadThread::run() exiting" << endl;
57 #ifdef DEBUG_FILE_READ_THREAD 58 SVDEBUG <<
"FileReadThread::finish()" << endl;
75 #ifdef DEBUG_FILE_READ_THREAD 76 SVDEBUG <<
"FileReadThread::finish() exiting" << endl;
111 cerr <<
"WARNING: FileReadThread::cancel: token " << token <<
" not found" << endl;
115 #ifdef DEBUG_FILE_READ_THREAD 116 SVDEBUG <<
"FileReadThread::cancel(" << token <<
") waking condition" << endl;
198 cerr <<
"WARNING: FileReadThread::done(" << token <<
"): request is still in queue (wait or cancel it)" << endl;
202 cerr <<
"WARNING: FileReadThread::done(" << token <<
"): request not found" << endl;
211 Profiler profiler(
"FileReadThread::process",
true);
213 int token =
m_queue.begin()->first;
218 #ifdef DEBUG_FILE_READ_THREAD 222 bool successful =
false;
223 bool seekFailed =
false;
236 static const size_t blockSize = 256 * 1024;
239 char *destination =
request.data;
242 size_t readSize = size;
243 if (readSize > blockSize) readSize = blockSize;
244 ssize_t br = ::read(
request.fd, destination, readSize);
250 if (br < ssize_t(readSize))
break;
252 destination += readSize;
259 ::perror(
"Seek failed");
260 cerr <<
"ERROR: FileReadThread::process: seek to " 261 <<
request.start <<
" failed" << endl;
265 ::perror(
"ERROR: FileReadThread::process: Read failed");
266 cerr <<
"ERROR: FileReadThread::process: read of " 268 <<
request.start <<
" failed" << endl;
270 }
else if (r < ssize_t(
request.size)) {
271 cerr <<
"WARNING: FileReadThread::process: read " 272 <<
request.size <<
" returned only " << r <<
" bytes" 286 request.successful = successful;
291 #ifdef DEBUG_FILE_READ_THREAD 292 SVDEBUG <<
"FileReadThread::process: done, marking as ready (success = " <<
m_readyRequests[token].successful <<
")" << endl;
295 #ifdef DEBUG_FILE_READ_THREAD 297 SVDEBUG <<
"FileReadThread::process: exiting" << endl;
299 SVDEBUG <<
"FileReadThread::process: request disappeared" << endl;
314 #ifdef DEBUG_FILE_READ_THREAD 315 SVDEBUG <<
"FileReadThread::notifyCancelled: token " << token << endl;
QWaitCondition m_condition
virtual bool haveRequest(int token)
virtual void cancel(int token)
RequestQueue m_cancelledRequests
RequestQueue m_readyRequests
std::set< int > m_newlyCancelled
virtual int request(const Request &request)
virtual bool isCancelled(int token)
virtual void done(int token)
virtual bool getRequest(int token, Request &request)
virtual bool isReady(int token)
Profile point instance class.