# File lib/poll.rb, line 295
 def poll( timeout=-1 ) # :yields: io, eventMask
		raise TypeError, "Timeout must be Numeric, not a #{timeout.type.name}" unless
			timeout.kind_of? Numeric
		timeout = timeout.to_f

		@events.clear

		unless @masks.empty?
			@events = _poll( @masks.to_a, timeout*1000 )

			# For each io that had an event happen, call any callback associated
			# with it, or failing that, any provided block
			@events.each {|io,evmask|
				if @callbacks.has_key?( io )
					args = @callbacks[ io ][ :args ]
					@callbacks[ io ][ :callback ].call( io,
													    EventMask::new(evmask),
													    *args )
				elsif block_given?
					yield( io, EventMask::new(evmask) )
				end
			}
		end

		@events.default = EventMask::new( 0 )
		return @events.length
	end