@@ -21,6 +21,9 @@ function dprintf(...)
21
21
end
22
22
printf (" %s:%d:%s:%s %s" , info .source , info .currentline , info .name , name , sprintf (... ))
23
23
end
24
+
25
+ -- Disable debug printing
26
+ -- Comment this out to enable debug output
24
27
dprintf = function (...)end
25
28
26
29
function _make_selector (me , who )
76
79
77
80
function say (f , ...)
78
81
local me = me ()
79
- printf (" %s says %q " , me .Name , sprintf (f , ... ))
82
+ printf (" %s says '%s' " , me .Name , sprintf (f , ... ))
80
83
end
81
84
82
85
function recv ()
90
93
function send (who , what )
91
94
local me = me ()
92
95
local selector = _make_selector (me , who )
93
- dprintf (" %s sending %q to %s" , me .Name , what , who )
96
+ dprintf (" %s sending '%s' to %s" , me .Name , what , who )
94
97
for co , child in pairs (child_by_co ) do
95
98
if selector (child ) then
96
- printf (" %s tells %s: %q " , me .Name , child .Name , what )
99
+ printf (" %s tells %s '%s' " , me .Name , child .Name , what )
97
100
table.insert (child .Msgs , {Src = me , Msg = what })
98
101
end
99
102
end
102
105
function any (...)
103
106
local waiters = {... }
104
107
return function ()
108
+ dprintf (" waiter %s" , waiters )
105
109
for i , waiter in ipairs (waiters ) do
106
110
local ready , resp = waiter ()
107
111
if ready then
@@ -126,7 +130,7 @@ function msg_from(who)
126
130
dprintf (" %s<%d> is waiting for %s" , me .Name , # me .Msgs , tostring (who ))
127
131
for i , msg in ipairs (me .Msgs ) do
128
132
if selector (msg .Src ) then
129
- printf (" %s hears %s %q " , me .Name , msg .Src .Name , msg .Msg )
133
+ printf (" %s hears %s '%s' " , me .Name , msg .Src .Name , msg .Msg )
130
134
table.remove (me .Msgs , i )
131
135
return true , msg
132
136
end
@@ -140,7 +144,9 @@ function minutes(m)
140
144
end
141
145
142
146
function seconds (s )
147
+ local me = me ()
143
148
return function ()
149
+ dprintf (" %s<%d> is waiting for %s" , me .Name , # me .Msgs , s )
144
150
s = s - 1
145
151
return s < 1 , nil
146
152
end
0 commit comments