1 #include "threadimpl.h"
7 typedef struct Note Note;
11 Proc *proc; /* recipient */
12 char s[ERRMAX]; /* arg2 */
15 static Note notes[128];
16 static Note *enotes = notes+nelem(notes);
17 static int (*onnote[NFN])(void*, char*);
18 static int onnotepid[NFN];
19 static Lock onnotelock;
22 threadnotify(int (*f)(void*, char*), int in)
25 int (*from)(void*, char*), (*to)(void*, char*);
30 topid = _threadgetproc()->pid;
48 delayednotes(Proc *p, void *v)
52 int (*fn)(void*, char*);
58 for(n=notes; n<enotes; n++){
61 if(onnotepid[i]!=p->pid || (fn = onnote[i])==nil)
67 _threaddebug(DBGNOTE, "Unhandled note %s, proc %p\n", n->s, p);
70 else if(strncmp(n->s, "sys:", 4)==0)
81 _threadnote(void *v, char *s)
86 _threaddebug(DBGNOTE, "Got note %s", s);
87 if(strncmp(s, "sys:", 4) == 0 && strcmp(s, "sys: write on closed pipe") != 0)
90 // if(_threadexitsallstatus){
91 // _threaddebug(DBGNOTE, "Threadexitsallstatus = '%s'\n", _threadexitsallstatus);
92 // _exits(_threadexitsallstatus);
95 if(strcmp(s, "threadint")==0 || strcmp(s, "interrupt")==0)
102 for(n=notes; n<enotes; n++)
103 if(canlock(&n->inuse))
106 sysfatal("libthread: too many delayed notes");
107 utfecpy(n->s, n->s+ERRMAX, s);
121 p = _threadgetproc();
132 p = _threadgetproc();
138 delayednotes(p, nil);