#include "ReadJob.h" #include "HttpServ.h" ReadJob::ReadJob(Handle * as, Handle * ad) : s(as), d(ad) { s->SetNonBlock(); d->SetNonBlock(); WaitFor(s, W4_READING); } ReadJob::~ReadJob() { } int ReadJob::Do() throw (GeneralException) { String buff; switch (current) { case 0: try { *s >> buff; } catch (IOAgain e) { WaitFor(s, W4_READING); Suspend(TASK_ON_HOLD); } case 1: try { *d << buff << endnl; } catch (IOAgain e) { current = 1; WaitFor(d, W4_WRITING); Suspend(TASK_ON_HOLD); } current = 0; if (buff == "") return TASK_DONE; } if (!s->IsClosed()) { WaitFor(s, W4_READING); Suspend(TASK_ON_HOLD); } return TASK_DONE; } String ReadJob::GetName() { return (String("ReadJob from ") + s->GetName() + " to " + d->GetName()); }