| 1 |
|
| MODULE = Punk::Queue PACKAGE = Punk::Queue::Cron |
| 2 |
|
| |
| 3 |
|
| # The parser surface: validation for the boot croak, next-occurrence for |
| 4 |
|
| # the scheduler, the tests and `punk-queue cron next`. |
| 5 |
|
| |
| 6 |
|
| # Validate an expression (+tz); croaks naming the offending token, or on |
| 7 |
|
| # a spec that can never fire. Returns 1. |
| 8 |
|
| IV |
| 9 |
|
| check(class, expr, tz = NULL) |
| 10 |
|
| SV *class |
| 11 |
|
| SV *expr |
| 12 |
|
| SV *tz |
| 13 |
|
| PREINIT: |
| 14 |
|
| pq_cron c; |
| 15 |
|
| pq_tz z; |
| 16 |
26 |
| STRLEN el, tl = 0; |
| 17 |
26 |
▶ | const char *es, *ts = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| const char *es, *ts = NULL; |
26 |
0 |
26 |
|
| 18 |
|
| CODE: |
| 19 |
|
| PERL_UNUSED_ARG(class); |
| 20 |
26 |
| es = SvPV_const(expr, el); |
| 21 |
33 |
▶ | if (tz && SvOK(tz)) ts = SvPV_const(tz, tl); |
Branch: 2 branches
| Branch | True | False | Total |
| if (tz && SvOK(tz)) ts = SvPV_const(tz, tl); |
9 |
17 |
26 |
| if (tz && SvOK(tz)) ts = SvPV_const(tz, tl); |
7 |
2 |
9 |
|
| 22 |
26 |
| pq_cron_compile(aTHX_ es, el, ts, tl, &c, &z); |
| 23 |
5 |
▶ | RETVAL = 1; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = 1; |
0 |
5 |
5 |
|
| 24 |
|
| OUTPUT: |
| 25 |
|
| RETVAL |
| 26 |
|
| |
| 27 |
|
| # The next occurrence strictly after $from (default now), as epoch |
| 28 |
|
| # seconds; undef when none exists inside the five-year horizon. |
| 29 |
|
| SV * |
| 30 |
|
| next_after(class, expr, from = NULL, tz = NULL) |
| 31 |
|
| SV *class |
| 32 |
|
| SV *expr |
| 33 |
|
| SV *from |
| 34 |
|
| SV *tz |
| 35 |
|
| PREINIT: |
| 36 |
|
| pq_cron c; |
| 37 |
|
| pq_tz z; |
| 38 |
445 |
| STRLEN el, tl = 0; |
| 39 |
445 |
▶ | const char *es, *ts = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| const char *es, *ts = NULL; |
0 |
445 |
445 |
|
| 40 |
|
| double f, n; |
| 41 |
|
| CODE: |
| 42 |
|
| PERL_UNUSED_ARG(class); |
| 43 |
445 |
| es = SvPV_const(expr, el); |
| 44 |
858 |
▶ | if (tz && SvOK(tz)) ts = SvPV_const(tz, tl); |
Branch: 2 branches
| Branch | True | False | Total |
| if (tz && SvOK(tz)) ts = SvPV_const(tz, tl); |
416 |
29 |
445 |
| if (tz && SvOK(tz)) ts = SvPV_const(tz, tl); |
413 |
3 |
416 |
|
| 45 |
445 |
| pq_cron_parse(aTHX_ es, el, &c); |
| 46 |
444 |
| pq_tz_parse(aTHX_ ts, tl, &z); |
| 47 |
443 |
▶ | f = (from && SvOK(from)) ? SvNV(from) : (double)time(NULL); |
Branch: 2 branches
| Branch | True | False | Total |
| f = (from && SvOK(from)) ? SvNV(from) : (double)time(NULL); |
443 |
0 |
443 |
| f = (from && SvOK(from)) ? SvNV(from) : (double)time(NULL); |
443 |
0 |
443 |
|
| 48 |
443 |
| n = pq_cron_next(aTHX_ &c, f, &z); |
| 49 |
443 |
▶ | if (n < 0) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (n < 0) XSRETURN_UNDEF; |
0 |
443 |
443 |
|
| 50 |
443 |
| RETVAL = newSVnv(n); |
| 51 |
|
| OUTPUT: |
| 52 |
|
| RETVAL |