4 * (c)Copyright 1993-2014, Matthew Dillon, All Rights Reserved. See the
5 * COPYRIGHT file at the base of the distribution.
10 typedef struct ThreadClass {
14 typedef struct ThreadWait {
19 isys_waitThreads(runctx_p ct __unused, Exp *exp __unused,
20 RefStor **prs __unused)
25 threadWaitTerminate();
26 restoreIFrame(&frame);
31 isys_wakeup(runctx_p ct, Exp *exp, RefStor **prs __unused)
40 rhs = exp->ex_Rhs->ex_Func(ct, exp->ex_Rhs, &rs);
42 if ((tw = hashLookup(tc->tc_Wid, HASH_THREADWAIT)) == NULL) {
44 "unable to locate thread rendezvous %d\n",
48 threadWakeupAll(&tw->tw_List);
54 isys_sleep(runctx_p ct, Exp *exp, RefStor **prs __unused)
65 rhs = exp->ex_Rhs->ex_Func(ct, exp->ex_Rhs, &rs);
67 if ((tw = hashLookup(tc->tc_Wid, HASH_THREADWAIT)) == NULL) {
69 "unable to locate thread rendezvous %d\n",
75 threadSleep(&tw->tw_List, rhs->ms);
77 threadStop(&tw->tw_List, 0);
78 restoreIFrame(&frame);
84 ic_thread_construct(Declaration *d, LValueStor *lvs)
90 if ((tw = hashLookup(tc->tc_Wid, HASH_THREADWAIT)) != NULL) {
92 "thread rendezvous %d already constructed!\n",
96 tw = zalloc(sizeof(ThreadWait));
97 initList(&tw->tw_List);
98 tc->tc_Wid = hashEnter(tw, HASH_THREADWAIT, -1);
102 ic_thread_destruct(Declaration *d, LValueStor *lvs)
108 if ((tw = hashLookup(tc->tc_Wid, HASH_THREADWAIT)) == NULL) {
110 "Unable to locate thread rendezvous to destruct: %d\n",
115 threadWakeupAll(&tw->tw_List);
116 zfree(tw, sizeof(ThreadWait));