… | |
… | |
434 | OpenCL can generate a number of (potentially) asynchronous events, for |
434 | OpenCL can generate a number of (potentially) asynchronous events, for |
435 | example, after compiling a program, to signal a context-related error or, |
435 | example, after compiling a program, to signal a context-related error or, |
436 | perhaps most important, to signal completion of queued jobs (by setting |
436 | perhaps most important, to signal completion of queued jobs (by setting |
437 | callbacks on OpenCL::Event objects). |
437 | callbacks on OpenCL::Event objects). |
438 | |
438 | |
|
|
439 | The OpenCL module converts all these callbacks into events - you can |
|
|
440 | still register callbacks, but they are not executed when your OpenCL |
|
|
441 | implementation calls the actual callback, but only later. Therefore, none |
|
|
442 | of the limitations of OpenCL callbacks apply to the perl implementation: |
|
|
443 | it is perfectly safe to make blocking operations from event callbacks, and |
|
|
444 | enqueued operations don't need to be flushed. |
|
|
445 | |
439 | To facilitate this, this module maintains an event queue - each |
446 | To facilitate this, this module maintains an event queue - each |
440 | time an asynchronous event happens, it is queued, and perl will be |
447 | time an asynchronous event happens, it is queued, and perl will be |
441 | interrupted. This is implemented via the L<Async::Interrupt> module. In |
448 | interrupted. This is implemented via the L<Async::Interrupt> module. In |
442 | addition, this module has L<AnyEvent> support, so it can seamlessly |
449 | addition, this module has L<AnyEvent> support, so it can seamlessly |
443 | integrate itself into many event loops. |
450 | integrate itself into many event loops. |
444 | |
451 | |
445 | Since this module is a bit hard to understand, here are some case examples: |
452 | Since L<Async::Interrupt> is a bit hard to understand, here are some case examples: |
446 | |
453 | |
447 | =head3 Don't use callbacks. |
454 | =head3 Don't use callbacks. |
448 | |
455 | |
449 | When your program never uses any callbacks, then there will never be any |
456 | When your program never uses any callbacks, then there will never be any |
450 | notifications you need to take care of, and therefore no need to worry |
457 | notifications you need to take care of, and therefore no need to worry |