void Domain::Done(Request *req, RequestFlag flag) { AutoLock lock(fLocker); Trace("%p.Done(", this); WriteRequest(req); Trace(", %d)\n", flag != doneRequest); Assert(req == fQueue && SetIn(runningRequest, req->state)); Assert((fQueue != NULL && fQueueEnd != NULL) || (fQueue == NULL && fQueueEnd == NULL)); Request *next = req->next; req->next = NULL; fQueue = next; if (next == NULL) fQueueEnd = NULL; SetExcl(req->state, runningRequest); SetIncl(req->state, flag); if (SetIn(doneRequest, req->state) && !SetIn(pendingRequest, req->state)) req->Resolved(); // can call delete req; if (next == NULL) { if (SetIn(pendingRequest, req->state)) { SetExcl(req->state, pendingRequest); Schedule(req); // calls Run } else { Trace("%p: last request\n", this); fEmptyQueueCV.Release(true); } } else { if (SetIn(pendingRequest, req->state)) { SetExcl(req->state, pendingRequest); Schedule(req); } Run(next); } Assert((fQueue != NULL && fQueueEnd != NULL) || (fQueue == NULL && fQueueEnd == NULL)); }