| 1 | package Punk::AsyncAwait; | ||
| 2 | |||
| 3 | # Future::AsyncAwait needs 5.16; Punk itself claims 5.10. Nothing in Punk | ||
| 4 | # loads this module, so a 5.10 perl installs and runs Punk exactly as before | ||
| 5 | # and only an application that asks for the keywords pays the higher floor. | ||
| 6 | 1 | ▶ | use 5.016; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 1 | our $VERSION = '0.69'; | |
| 11 | |||
| 12 | 1 | ▶ | use Punk::Future (); # the AWAIT_* methods live in Punk's XS, and a |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | # controller may never have loaded Punk itself | ||
| 14 | 1 | ▶ | use Future::AsyncAwait (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | |||
| 16 | # `async` and `await` are parser keywords, not subs - they need a real keyword | ||
| 17 | # plugin, which is what Future::AsyncAwait installs through the lexical hints | ||
| 18 | # hash. Forwarding its import from ours installs them into whatever scope is | ||
| 19 | # compiling when the `use` line is reached, which is the caller's file. | ||
| 20 | # | ||
| 21 | # The default future class goes first so a caller's own choice wins: the hint | ||
| 22 | # is assigned once per occurrence, last one through. | ||
| 23 | 5 | ▶ | sub import { |
|
Subroutine
import: called CC=1 SCAR=0.0
| |||
| 24 | 5 | my $class = shift; | |
| 25 | 5 | Future::AsyncAwait->import( future_class => 'Punk::Future', @_ ); | |
| 26 | } | ||
| 27 | |||
| 28 | 0 | ▶ | sub unimport { |
|
Subroutine
unimport: not called CC=1 SCAR=6.9
| |||
| 29 | 0 | my $class = shift; | |
| 30 | 0 | Future::AsyncAwait->unimport(@_); | |
| 31 | } | ||
| 32 | |||
| 33 | 1 | 1; | |
| 34 | |||
| 35 | __END__ | ||