pomodoro: some tuning
This commit is contained in:
		
							parent
							
								
									3d44081789
								
							
						
					
					
						commit
						6d8008cdf8
					
				| @ -68,7 +68,7 @@ class EventLoop | ||||
| 		else | ||||
| 			timer.index = @timers.size | ||||
| 			@timers.push timer | ||||
| 			heapify_up @timers.size - 1 | ||||
| 			heapify_up timer.index | ||||
| 		end | ||||
| 	end | ||||
| 
 | ||||
| @ -126,7 +126,7 @@ private | ||||
| 
 | ||||
| 	def dispatch_timers | ||||
| 		now = Time.new | ||||
| 		while not @timers.empty? and @timers[0].when < now do | ||||
| 		while not @timers.empty? and @timers[0].when <= now do | ||||
| 			@timers[0].callback.call | ||||
| 			remove_timer_at 0 | ||||
| 		end | ||||
| @ -134,7 +134,7 @@ private | ||||
| 
 | ||||
| 	def nearest_timeout | ||||
| 		return nil if @timers.empty? | ||||
| 		timeout = @timers[0].when - Time.new | ||||
| 		timeout = @timers[0].until | ||||
| 		if timeout < 0 then 0 else timeout end | ||||
| 	end | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user