#include "ReadJob.h" #include "HttpServ.h" ReadJob::ReadJob(Handle * as, Handle * ad) : s(as), d(ad) { WaitFor(s); WaitFor(d); } ReadJob::~ReadJob() { } int ReadJob::Do() throw (GeneralException) { String buff; cerr << "ReadJob running...\n"; switch (current) { case 0: try { cerr << "Trying to read...\n"; *s >> buff; } catch (IOAgain e) { cerr << "Suspending ReadJob to wait for reading...\n"; throw TaskSwitch(); } cerr << "Read some bytes...\n"; case 1: try { *d << buff << endnl; } catch (IOAgain e) { cerr << "Suspending ReadJob to wait for writing...\n"; current = 1; throw TaskSwitch(); } current = 0; cerr << "Wrote some bytes...\n"; if (buff == "") return TASK_DONE; } if (!s->IsClosed()) { throw TaskSwitch(); } return TASK_DONE; } String ReadJob::GetName() { return (String("ReadJob from ") + s->GetName() + " to " + d->GetName()); }