Method: Async::Scheduler#close

Defined in:
lib/async/scheduler.rb

#closeObject

Terminate all child tasks and close the scheduler.



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/async/scheduler.rb', line 149

def close
	unless @children.nil?
		self.run_loop do
			until self.terminate
				self.run_once!
			end
		end
	end
	
	Kernel.raise "Closing scheduler with blocked operations!" if @blocked > 0
ensure
	# We want `@selector = nil` to be a visible side effect from this point forward, specifically in `#interrupt` and `#unblock`. If the selector is closed, then we don't want to push any fibers to it.
	if selector = @selector
		@selector = nil
		selector.close
	end
	
	if worker_pool = @worker_pool
		@worker_pool = nil
		worker_pool.close
	end
	
	consume
end