Browse Source

Tested non-blocking read on Linux.


git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@55 d34b734f-a00e-4b39-a726-e4eeb87269ab
adeniz_1
adeniz 10 years ago
parent
commit
8892101288
1 changed files with 3 additions and 23 deletions
  1. 3
    23
      child.cpp

+ 3
- 23
child.cpp View File

@@ -31,7 +31,6 @@
#include <cerrno>
#endif
#include <iostream> // Temporary.
#include <stdexcept>
#include "child.hpp"
@@ -522,7 +521,7 @@ namespace CodeDweller {
std::streambuf::int_type
Child::ReadStreambuf::underflow() {
std::cout << "underflow()." << std::endl; // debug
// Check for empty buffer.
if (gptr() < egptr()) {
@@ -530,7 +529,7 @@ namespace CodeDweller {
return traits_type::to_int_type(*gptr());
}
std::cout << "need to fill buffer." << std::endl; // debug
// Need to fill the buffer.
char *base = &(buffer.front());
char *start = base;
@@ -556,18 +555,10 @@ namespace CodeDweller {
}
#else
ssize_t nBytesRead;
std::cout << "Requesting read of " << buffer.size() - (start - base)
<< " bytes" << std::endl; // debug
nBytesRead = read(inputFileDescriptor,
start,
buffer.size() - (start - base));
// debug
std::cout << "nBytesRead: " << nBytesRead << std::endl; // debug
for (int i = 0; i < nBytesRead; i++) {
std::cout << (char) start[i];
}
std::cout << std::endl;
// end of debug
if (-1 == nBytesRead) {
return traits_type::eof();
}
@@ -581,8 +572,6 @@ namespace CodeDweller {
// Update buffer pointers.
setg(base, start, start + nBytesRead);
std::cout << "underflow() return." << std::endl; // debug
return traits_type::to_int_type(*gptr());
}
@@ -641,15 +630,6 @@ namespace CodeDweller {
ssize_t nBytesWritten;
nBytesWritten = write(outputFileDescriptor, pbase(), nBytes);
// debug
std::cout << "flushBuffer(). Requested to write " << nBytes << " bytes, "
<<"wrote " << nBytesWritten << " bytes." << std::endl;
char *ch = pbase();
for (int i = 0; i < nBytesWritten; i++) {
std::cout << (char) ch[i];
}
std::cout << std::endl;
// end of debug.
#endif

Loading…
Cancel
Save