Up

Module Schedule = Async_extra.Schedule

Signature

type zoned = Core.Schedule.zoned =
| Zoned
type unzoned = Core.Schedule.unzoned =
| Unzoned
module Inclusive_exclusive : sig .. end
type ('a, 'b) t = ('a, 'b) Core.Schedule.t =
| In_zone : Core.Time.Zone.t * (unzoned, 'b0) t -> (zoned, 'b0) t
| Tag : 'b1 * ('a0, 'b1) t -> ('a0, 'b1) t
| And : ('a1, 'b2) t list -> ('a1, 'b2) t
| Or : ('a2, 'b3) t list -> ('a2, 'b3) t
| Not : ('a3, 'b4) t -> ('a3, 'b4) t
| If_then_else : (('a4, 'b5) t * ('a4, 'b5) t * ('a4, 'b5) t) -> ('a4, 'b5) t
| Shift : Core.Time.Span.t * ('a5, 'b6) t -> ('a5, 'b6) t
| At : Core.Time.Ofday.t list -> (unzoned, 'b8) t
| Secs : int list -> (unzoned, 'b9) t
| Mins : int list -> (unzoned, 'b10) t
| Hours : int list -> (unzoned, 'b11) t
| Weekdays : Core_kernel.Std.Day_of_week.t list -> (unzoned, 'b12) t
| Days : int list -> (unzoned, 'b13) t
| Weeks : int list -> (unzoned, 'b14) t
| Months : Core_kernel.Std.Month.t list -> (unzoned, 'b15) t
| On : Core.Date.t list -> (unzoned, 'b16) t
| Always : ('a6, 'b19) t
| Never : ('a7, 'b20) t
val compare : ('b -> 'b -> int) -> ('a, 'b) t -> ('a, 'b) t -> int
val to_string_zoned : (zoned, 'b) t -> string_of_tag:('b -> string) -> string
module Stable : sig .. end
val includes : (zoned, 'b) t -> Core.Time.t -> bool
val tags : (zoned, 'tag) t -> Core.Time.t -> [
| `Included of 'tag list
| `Not_included
]
val all_tags : (zoned, 'tag) t -> tag_comparator:('tag, 'cmp) Core_kernel.Std.Comparator.t -> ('tag, 'cmp) Core_kernel.Std.Set.t
val fold_tags : (zoned, 'tag) t -> init:'m -> f:('m -> 'tag -> 'm) -> Core.Time.t -> 'm option
val map_tags : ('a, 'b) t -> f:('b -> 'c) -> ('a, 'c) t
module Event : sig .. end
type ('tag, 'a) emit = ('tag, 'a) Core.Schedule.emit =
| Transitions : ('tag0, [
| `Enter of Core.Time.t * 'tag0 list
| `Leave of Core.Time.t
| `No_change_until_at_least of [
| `In_range
| `Out_of_range
] * Core.Time.t
]) emit
| Transitions_and_tag_changes : ('tag1 -> 'tag1 -> bool) -> ('tag1, [
| `Change_tags of Core.Time.t * 'tag1 list
| `Enter of Core.Time.t * 'tag1 list
| `Leave of Core.Time.t
| `No_change_until_at_least of [
| `In_range
| `Out_of_range
] * Core.Time.t
]) emit
val to_endless_sequence : (zoned, 'tag) t -> start_time:Core.Time.t -> emit:('tag, 'a) emit -> [
| `Started_in_range of 'tag list * 'a Core_kernel.Std.Sequence.t
| `Started_out_of_range of 'a Core_kernel.Std.Sequence.t
]
val next_enter_between : (zoned, 'tag) t -> Core.Time.t -> Core.Time.t -> Core.Time.t option
val next_leave_between : (zoned, 'tag) t -> Core.Time.t -> Core.Time.t -> Core.Time.t option
type ('tag, 'output) pipe_emit =
| Transitions : ('tag, 'tag Event.transition) pipe_emit
| Transitions_and_tag_changes : ('tag -> 'tag -> bool) -> ('tag, [ ]) pipe_emit

in Transitions_and_tag_changes equality for the tag type must be given

val to_pipe : (zoned, 'tag) t -> start_time:Core.Std.Time.t -> emit:('tag, 'output) pipe_emit -> unit -> [
| `Started_in_range of 'tag list * 'output Async_extra.Import.Pipe.Reader.t
| `Started_out_of_range of 'output Async_extra.Import.Pipe.Reader.t
]

to_pipe t ~start_time ~emit ?stop () produces a pipe containing the events from to_endless_sequence ~start_time t ~emit, with `No_change_until_at_least filtered out and each event added only at or after its scheduled time.

val next_event : (zoned, 'tag) t -> event:[
| `Enter
| `Leave
] -> stop:unit Async_extra.Import.Deferred.t -> ?after:Core.Std.Time.t -> unit -> Core.Std.Time.t Async_extra.Import.Deferred.t

next_event t ~event ~stop ~after () waits for the time of the next event matching event in t starting at time after. At that time, the resulting deferred is determined and filled with the time of the event.

If stop becomes determined before the next event, the resulting deferred is never filled and the computation to find the next event stops. If the caller intends to never use the returned deferred stop should be filled or the background computation will continue to keep the deferred alive until the event occurs.

This function is a good choice for handling a single event during the run of a program, like scheduling shutdown. If the intention is to follow along with all events in a schedule it is preferable to call to_pipe or to_endless_sequence (in the non-async module).

val every_enter : (zoned, _) t -> ?start:Core.Std.Time.t -> ?stop:unit Async_extra.Import.Deferred.t -> ?continue_on_error:bool -> ?start_in_range_is_enter:bool -> (enter:Core.Std.Time.t -> leave:Core.Std.Time.t Async_extra.Import.Deferred.t -> unit) -> unit

every_enter t ~start ~stop ~continue_on_error ~start_in_range_is_enter f calls f for each contiguous block of time in t starting at start and continuing until stop becomes determined.

For each block of time with start time enter and end time leave_time, f is called with f ~enter ~leave, where leave is a deferred that becomes determined at leave_time with the value leave_time.

If includes t start && start_in_range_is_enter, then f will be called as soon as possible after start with enter = start. Otherwise, f will not be called for any block of time that includes start.

If continue_on_error = false and f (or any async job started by f) raises an error, f will no longer be called, and all undetermined leave deferreds will remain unfulfilled.

If stop is fulfilled then no further calls to f will be made and all undetermined leave deferreds will remain unfulfilled.

val every_tag_change : (zoned, 'tag) t -> ?start:Core.Std.Time.t -> ?stop:unit Async_extra.Import.Deferred.t -> ?continue_on_error:bool -> ?start_in_range_is_enter:bool -> tag_equal:('tag -> 'tag -> bool) -> (tags:'tag list -> enter:Core.Std.Time.t -> leave:Core.Std.Time.t Async_extra.Import.Deferred.t -> unit) -> unit

every_tag_change t f calls f for each contiguous block of time in t where the set of tags in effect remains stable (according to tag_equal).

Moving from a range where the schedule is not in effect to one where it is in effect with no tags is considered a tag change.

For each block of time tagged with tags and start time enter and end time leave_time, f is called with f ~tags ~enter ~leave, where leave is a deferred that becomes determined at leave_time with the value leave_time.

stop, continue_on_error, and start_in_range_is_enter act as documented in every_enter.