module FDB

def self.init()

def self.init()
  @@network_thread_monitor.synchronize do
    if !@@network_thread.nil?
      raise Error.new(2000)
    end
    begin
      @@network_thread = Thread.new do
        @@network_thread_monitor.synchronize do
          # Don't start running until init releases this
        end
        # puts "Starting FDB network"
        begin
          FDBC.check_error FDBC.fdb_run_network
        rescue Error => e
          $stderr.puts "Unhandled error in FoundationDB network thread: #{e.to_s}"
        end
      end
      FDBC.check_error FDBC.fdb_setup_network
    rescue
      @@network_thread.kill
      @@network_thread = nil
      raise
    end
  end
  nil
end