class MockDnsServer::ServerContext
Attributes
conditional_actions[R]
history[R]
host[R]
mutex[R]
port[R]
server[R]
timeout_secs[R]
verbose[R]
Public Class Methods
new(server, options = {})
click to toggle source
def shutdown_requested?; @shutdown_requested end def request_shutdown; @shutdown_requested = true end
# File lib/mock_dns_server/server_context.rb, line 24 def initialize(server, options = {}) @server = server @port = options[:port] @host = options[:host] @timeout_secs = options[:timeout_secs] @verbose = options[:verbose] @mutex = Mutex.new @conditional_actions = ConditionalActions.new(self) @history = History.new(self) end
Public Instance Methods
with_mutex(&block)
click to toggle source
# File lib/mock_dns_server/server_context.rb, line 36 def with_mutex(&block) start_time = Time.now duration = ->() do now = Time.now elapsed_in_usec = (now - start_time) * 1_000_000 start_time = now "#{elapsed_in_usec} usec" end #puts "#{Thread.current}: Waiting for mutex..." mutex.synchronize do #puts "time to get mutex: #{duration.()}" block.call #puts "time using mutex: #{duration.()}" end end