summaryrefslogtreecommitdiff
path: root/lib/CopyJob.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/CopyJob.cc
parent701e4e617e00e7f0ed4f07c1c4bcc20f6fb6ce4d (diff)
Still working on task system.
Diffstat (limited to 'lib/CopyJob.cc')
-rw-r--r--lib/CopyJob.cc22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/CopyJob.cc b/lib/CopyJob.cc
index f1d3310..e46e3da 100644
--- a/lib/CopyJob.cc
+++ b/lib/CopyJob.cc
@@ -5,27 +5,29 @@ CopyJob::CopyJob(Handle * as, Handle * ad, ssize_t asiz) : s(as), d(ad), siz(asi
CopyJob::~CopyJob() { }
-int CopyJob::Do() {
+int CopyJob::Do() throw (GeneralException) {
int r, tr;
while (!s->IsClosed() || (siz != cursiz)) {
- if (!current) {
+ switch (current) {
+ case 0:
tr = siz >= 0 ? siz - cursiz : COPY_BUFSIZ;
try {
r = s->read(buffer, MIN(COPY_BUFSIZ, tr));
}
catch (IOAgain e) {
- return TASK_ON_HOLD;
+ throw TaskSwitch();
+ }
+ case 1:
+ try {
+ d->write(buffer, r);
+ }
+ catch (IOAgain e) {
+ current = 1;
+ throw TaskSwitch();
}
current = 0;
}
- try {
- d->write(buffer, r);
- }
- catch (IOAgain e) {
- current = 1;
- return TASK_ON_HOLD;
- }
cursiz += r;
}
}