… | |
… | |
38 | SIG_ATOMIC_MAX (guaranteed to allow at least 0..127). |
38 | SIG_ATOMIC_MAX (guaranteed to allow at least 0..127). |
39 | |
39 | |
40 | Since this kind of interruption is fast, but can only interrupt a |
40 | Since this kind of interruption is fast, but can only interrupt a |
41 | I<running> interpreter, there is optional support for also signalling a |
41 | I<running> interpreter, there is optional support for also signalling a |
42 | pipe - that means you can also wait for the pipe to become readable while |
42 | pipe - that means you can also wait for the pipe to become readable while |
|
|
43 | #TODO# |
43 | |
44 | |
44 | =over 4 |
45 | =over 4 |
45 | |
46 | |
46 | =cut |
47 | =cut |
47 | |
48 | |
… | |
… | |
165 | C<$value> must be in the valid range for a C<sig_atomic_t> (0..127 is |
166 | C<$value> must be in the valid range for a C<sig_atomic_t> (0..127 is |
166 | portable). |
167 | portable). |
167 | |
168 | |
168 | =item $async->block |
169 | =item $async->block |
169 | |
170 | |
170 | Sometimes you need a "critical section" of code where |
|
|
171 | |
|
|
172 | =item $async->unblock |
171 | =item $async->unblock |
|
|
172 | |
|
|
173 | Sometimes you need a "critical section" of code that will not be |
|
|
174 | interrupted by an Async::Interrupt. This can be implemented by calling C<< |
|
|
175 | $async->block >> before the critical section, and C<< $async->unblock >> |
|
|
176 | afterwards. |
|
|
177 | |
|
|
178 | Note that there must be exactly one call of C<unblock> for ever<y previous |
|
|
179 | call to C<block> (i.e. calls can nest). |
|
|
180 | |
|
|
181 | Since ensuring this in the presense of exceptions and threads is |
|
|
182 | usually more difficult than you imagine, I recommend using C<< |
|
|
183 | $async->scoped_block >> instead. |
|
|
184 | |
|
|
185 | =item $async->scope_block |
|
|
186 | |
|
|
187 | This call C<< $async->block >> and installs a handler that is called when |
|
|
188 | the current scope is exited (via an exception, by canceling the Coro |
|
|
189 | thread, by calling last/goto etc.). |
|
|
190 | |
|
|
191 | This is the recommended (and fastest) way to implement critical sections. |
173 | |
192 | |
174 | =cut |
193 | =cut |
175 | |
194 | |
176 | 1; |
195 | 1; |
177 | |
196 | |