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