Changeset 31:bbd688924703 in xplcommon for src/xplcommon/BlockingStream.cc
- Timestamp:
- 01/02/13 13:58:25 (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/xplcommon/BlockingStream.cc
r30 r31 46 46 //------------------------------------------------------------------------------ 47 47 48 bool BlockingStream::isInterrupted()48 inline bool BlockingStream::checkInterrupted() 49 49 { 50 if (failed()) return false;51 52 50 if (!interrupted) { 53 51 interrupted = event.check(); … … 83 81 //------------------------------------------------------------------------------ 84 82 83 bool BlockingStream::skip(size_t length) 84 { 85 ReadingBuffer& readingBuffer = stream.getReadingBuffer(); 86 while (length>0) { 87 size_t toSkip = min(length, readingBuffer.getLength() - readingOffset); 88 readingOffset += toSkip; 89 length -= toSkip; 90 91 if (length!=0) { 92 if (!fill()) return false; 93 } 94 } 95 96 return true; 97 } 98 99 //------------------------------------------------------------------------------ 100 85 101 bool BlockingStream::write(const void* src, size_t length) 86 102 { … … 105 121 { 106 122 WritingBuffer& writingBuffer = stream.getWritingBuffer(); 107 while ( !failed()) {108 if ( isInterrupted()) return false;123 while (*this) { 124 if (checkInterrupted()) return false; 109 125 110 126 if (writingBuffer.write()) { … … 112 128 } else if (writingBuffer.failed()) { 113 129 setErrorCode(writingBuffer.getErrorCode()); 114 return false;115 130 } else { 116 131 Waiter* waiter = stream.getWaiter(); … … 132 147 readingBuffer.reset(); 133 148 readingOffset = 0; 134 while ( true) {135 if ( isInterrupted()) return false;149 while (*this) { 150 if (checkInterrupted()) return false; 136 151 137 152 if (readingBuffer.read()) { 138 return !readingBuffer.isEmpty(); 153 eof = readingBuffer.isEmpty(); 154 return !eof; 139 155 } else if (readingBuffer.failed()) { 140 156 setErrorCode(readingBuffer.getErrorCode()); 141 return false;142 157 } else { 143 158 Waiter* waiter = stream.getWaiter(); … … 149 164 } 150 165 } 166 return false; 151 167 } 152 168
Note:
See TracChangeset
for help on using the changeset viewer.