summaryrefslogtreecommitdiff
path: root/lib/ReadJob.cc
diff options
context:
space:
mode:
authorPixel <Pixel>2001-11-15 14:52:43 +0000
committerPixel <Pixel>2001-11-15 14:52:43 +0000
commit3f720784d55707024fff675a5238fde0168d1a40 (patch)
tree84a5b9843ede69aaf76cd9b791686b2a3ea7c3d7 /lib/ReadJob.cc
parent8694409f2a5531e9f3263e8a42248a3ca91ac14f (diff)
More work into TaskMan...
Diffstat (limited to 'lib/ReadJob.cc')
-rw-r--r--lib/ReadJob.cc55
1 files changed, 30 insertions, 25 deletions
diff --git a/lib/ReadJob.cc b/lib/ReadJob.cc
index 6640d82..9f037d9 100644
--- a/lib/ReadJob.cc
+++ b/lib/ReadJob.cc
@@ -1,7 +1,10 @@
#include "ReadJob.h"
#include "HttpServ.h"
-ReadJob::ReadJob(Handle * as, Handle * ad) : s(as), d(ad) { }
+ReadJob::ReadJob(Handle * as, Handle * ad) : s(as), d(ad) {
+ WaitFor(s);
+ WaitFor(d);
+}
ReadJob::~ReadJob() { }
@@ -10,31 +13,33 @@ int ReadJob::Do() throw (GeneralException) {
cerr << "ReadJob running...\n";
- while (!s->IsClosed()) {
- 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;
+ 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;