U vi/@sdddlmZmZmZmZddlmZmZddlmZm Z m Z ddl m Z edZ Gddde Zd S) )AnyOptionalTypeVarcast)abctyping)CompositeDisposable DisposableSingleAssignmentDisposable)PeriodicScheduler_TStatecseZdZdZeddfdd Zdejeje e e e e j ddd Zdeje e e e j d d d Zdejeje e e e j d ddZdejeje e e e j d ddZdejeje e e e j dddZZS) GtkSchedulerzA scheduler that schedules work via the GLib main loop used in GTK+ applications. See https://wiki.gnome.org/Projects/PyGObject N)glibreturncst||_dS)aCreate a new GtkScheduler. Args: glib: The GLib module to use; typically, you would get this by >>> import gi >>> gi.require_version('Gtk', '3.0') >>> from gi.repository import GLib N)super__init___glib)selfr __class__Z/opt/alt/python38/lib/python3.8/site-packages/reactivex/scheduler/mainloop/gtkscheduler.pyrs zGtkScheduler.__init__F)timeactionstateperiodicrcsptdt|d}tdttdfdd }j||dddfdd }tt |S) Nrg@@F)_rcsBrdSr"ttjtnjttjtd_S)NFr)rrScheduledPeriodicActionr Z invoke_actionScheduledActionZ disposable)rrrZsadrrstoppedrr timer_handler1sz1GtkScheduler._gtk_schedule..timer_handler)rcsddS)NTrr)r"rrdisposeAsz+GtkScheduler._gtk_schedule..dispose) maxintZ to_secondsr rboolrZ timeout_addrr )rrrrrmsecsr#r$rr!r _gtk_schedule#szGtkScheduler._gtk_schedule)rrrcCs|d||S)a!Schedules an action to be executed. Args: action: Action to be executed. state: [Optional] state to be given to the action function. Returns: The disposable object used to cancel the scheduled action (best effort). gr))rrrrrrscheduleGs zGtkScheduler.schedule)duetimerrrcCs|j|||dS)auSchedules an action to be executed after duetime. Args: duetime: Relative time after which to execute the action. action: Action to be executed. state: [Optional] state to be given to the action function. Returns: The disposable object used to cancel the scheduled action (best effort). rr*rr,rrrrrschedule_relativeVszGtkScheduler.schedule_relativecCs ||}|j||j||dS)aoSchedules an action to be executed at duetime. Args: duetime: Absolute time at which to execute the action. action: Action to be executed. state: [Optional] state to be given to the action function. Returns: The disposable object used to cancel the scheduled action (best effort). r) to_datetimer)nowr-rrrschedule_absoluteis zGtkScheduler.schedule_absolute)periodrrrcCs|j|||ddS)aSchedules a periodic piece of work to be executed in the loop. Args: period: Period in seconds for running the work repeatedly. action: Action to be executed. state: [Optional] state to be given to the action function. Returns: The disposable object used to cancel the scheduled action (best effort). T)rrr*)rr2rrrrrschedule_periodic~szGtkScheduler.schedule_periodic)NF)N)N)N)N)__name__ __module__ __qualname____doc__rrrZAbsoluteOrRelativeTimeZScheduledSingleOrPeriodicActionr rr'rZDisposableBaser)r r+Z RelativeTimer.Z AbsoluteTimer1rr3 __classcell__rrrrrsL %   rN)rrrrrZ reactivexrZreactivex.disposablerr r Zperiodicschedulerr r rrrrrs