From 9235fbc2a736da2c68eb2dc0a3c1007b4a202d5e Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 13 Nov 2001 11:50:37 +0000 Subject: Still working on task system. --- lib/CopyJob.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'lib/CopyJob.cc') 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; } } -- cgit v1.2.3