This commit is contained in:
cinap_lenrek 2015-10-15 13:22:48 +02:00
commit 2f99484b9d
3 changed files with 23 additions and 0 deletions

View file

@ -287,3 +287,4 @@ void srvrelease(Srv *);
Reqqueue* reqqueuecreate(void);
void reqqueuepush(Reqqueue*, Req*, void (*)(Req *));
void reqqueueflush(Reqqueue*, Req*);
void reqqueuefree(Reqqueue*);

View file

@ -29,6 +29,7 @@ struct Reqqueue
Reqqueue* reqqueuecreate(void);
void reqqueuepush(Reqqueue *q, Req *r, void (*f)(Req *));
void reqqueueflush(Reqqueue *q, Req *r);
void reqqueuefree(Reqqueue *q);
.fi
.SH DESCRIPTION
.I Reqqueue
@ -55,6 +56,10 @@ by
which will remove the request immediately if processing has
not started. If processing has been started, the process
will be interrupted.
.PP
.I Reqqueuefree
frees a queue.
No new requests should be send to the queue and it will be freed once all requests in it have been processed.
.SH SOURCE
.B /sys/src/lib9p/queue.c
.SH SEE ALSO

View file

@ -35,8 +35,14 @@ _reqqueueproc(void *v)
memset(&r->qu, 0, sizeof(r->qu));
q->cur = r;
qunlock(q);
if(f == nil)
break;
f(r);
}
free(r);
free(q);
threadexits(nil);
}
Reqqueue *
@ -83,3 +89,14 @@ reqqueueflush(Reqqueue *q, Req *r)
respond(r, "interrupted");
}
}
void
reqqueuefree(Reqqueue *q)
{
Req *r;
if(q == nil)
return;
r = emalloc9p(sizeof(Req));
reqqueuepush(q, r, nil);
}