aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/upas/nfs/thread.c
blob: bb40def13ac755337573f4b0b3d357d2e232cf56 (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
38
#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);
}