OpenCL
view release on metacpan or search on metacpan
the C<until> loop following the marker call will be interrupted by the
callback:
my $e = $queue->marker;
my $flag;
$e->cb (sub { $flag = 1 });
1 until $flag;
# $flag is now 1
The reason why you shouldn't blindly copy the above code is that
busy waiting is a really really bad thing, and really really bad for
performance.
While at first this asynchronous business might look exciting, it can be
really hard, because you need to be prepared for the callback code to be
executed at any time, which limits the amount of things the callback code
can do safely.
This can be mitigated somewhat by using C<<
$OpenCL::INTERRUPT->scope_block >> (see the L<Async::Interrupt>
documentation for details).
For example, in the following code (*THAT YOU SHOULD NOT COPY*), the
"until" loop following the marker call will be interrupted by the
callback:
my $e = $queue->marker;
my $flag;
$e->cb (sub { $flag = 1 });
1 until $flag;
# $flag is now 1
The reason why you shouldn't blindly copy the above code is that busy
waiting is a really really bad thing, and really really bad for
performance.
While at first this asynchronous business might look exciting, it can be
really hard, because you need to be prepared for the callback code to be
executed at any time, which limits the amount of things the callback
code can do safely.
This can be mitigated somewhat by using
"$OpenCL::INTERRUPT->scope_block" (see the Async::Interrupt
( run in 0.251 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )