summaryrefslogtreecommitdiff
path: root/lib/ReadJob.cc
diff options
context:
space:
mode:
authorPixel <Pixel>2001-11-13 11:50:37 +0000
committerPixel <Pixel>2001-11-13 11:50:37 +0000
commit9235fbc2a736da2c68eb2dc0a3c1007b4a202d5e (patch)
tree4045976599c1738646e6debccefa90d00107a42e /lib/ReadJob.cc
parent701e4e617e00e7f0ed4f07c1c4bcc20f6fb6ce4d (diff)
Still working on task system.
Diffstat (limited to 'lib/ReadJob.cc')
-rw-r--r--lib/ReadJob.cc33
1 files changed, 16 insertions, 17 deletions
diff --git a/lib/ReadJob.cc b/lib/ReadJob.cc
index a63eeca..2c244ad 100644
--- a/lib/ReadJob.cc
+++ b/lib/ReadJob.cc
@@ -5,37 +5,36 @@ ReadJob::ReadJob(Handle * as, Handle * ad) : s(as), d(ad), current(0) { }
ReadJob::~ReadJob() { }
-int ReadJob::Do() {
- int r;
+int ReadJob::Do() throw (GeneralException) {
String buff;
cerr << "ReadJob running...\n";
while (!s->IsClosed()) {
- if (!current) {
- r = 0;
+ switch (current) {
+ case 0:
try {
cerr << "Trying to read...\n";
*s >> buff;
}
catch (IOAgain e) {
cerr << "Suspending ReadJob to wait for reading...\n";
- r = 1;
+ throw TaskSwitch();
}
- if (r) Suspend();
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;
}
- r = 0;
- try {
- *d << buff << endnl;
- }
- catch (IOAgain e) {
- cerr << "Suspending ReadJob to wait for writing...\n";
- r = 1;
- }
- if (r) Suspend();
- cerr << "Wrote some bytes...\n";
- if (buff == "") return TASK_DONE;
}
return TASK_DONE;