aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/upas/nfs/thread.c
blob: b4c893ee0db739ffbbe15c0d3abad98f99c1d237 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "a.h"

typedef struct New New;
struct New
{
	void (*fn)(void*);
	void *arg;
};

Channel *mailthreadchan;

void
mailthread(void (*fn)(void*), void *arg)
{
	New n;

	n.fn = fn;
	n.arg = arg;
	send(mailthreadchan, &n);
}

void
mailproc(void *v)
{
	New n;

	USED(v);
	while(recv(mailthreadchan, &n) == 1)
		threadcreate(n.fn, n.arg, STACK);
}

void
mailthreadinit(void)
{
	mailthreadchan = chancreate(sizeof(New), 0);
	proccreate(mailproc, nil, STACK);
}