| 5 | | run := method( |
| 6 | | ini := Date now asNumber |
| 7 | | current := Date now asNumber |
| 8 | | loop ( |
| 9 | | current = Date now asNumber |
| 10 | | diff := (current - ini) |
| 11 | | if(period < diff) then ( |
| 12 | | ini = current |
| 13 | | command @@call |
| 14 | | yield |
| 15 | | ) |
| 16 | | System sleep(0.01) |
| | 5 | init := method( |
| | 6 | self initial := Date now asNumber |
| | 7 | self current := Date now asNumber |
| | 8 | ) |
| | 9 | execute := method( |
| | 10 | self current = Date now asNumber |
| | 11 | diff := (self current - self initial) |
| | 12 | if(period < diff) then ( |
| | 13 | command @@call |
| | 14 | ) |
| | 15 | ) |
| | 16 | ) |
| | 17 | ScheduleFixRateUnit := ScheduleUnit clone do ( |
| | 18 | execute := method( |
| | 19 | self current = Date now asNumber |
| | 20 | diff := (self current - self initial) |
| | 21 | if(period < diff) then ( |
| | 22 | self initial = self current |
| | 23 | command @@call |
| | 24 | ) |
| | 25 | ) |
| | 26 | ) |
| | 27 | ScheduleFixDelayUnit := ScheduleUnit clone do ( |
| | 28 | execute := method( |
| | 29 | self current = Date now asNumber |
| | 30 | diff := (self current - self initial) |
| | 31 | if(period < diff) then ( |
| | 32 | command call |
| | 33 | self initial = Date now asNumber |
| 21 | | unit := ScheduleFixRateUnit clone |
| | 38 | addUnit(ScheduleUnit clone, command, period) |
| | 39 | ) |
| | 40 | scheduleWithFixedRate := method(command, period, |
| | 41 | addUnit(ScheduleFixRateUnit clone, command, period) |
| | 42 | ) |
| | 43 | scheduleWithFixedDelay := method(command, period, |
| | 44 | addUnit(ScheduleFixDelayUnit clone, command, period) |
| | 45 | ) |
| | 46 | addUnit := method(unit, command, period, |