Class: RethinkDB::EM_Guard
- Inherits:
-
Object
- Object
- RethinkDB::EM_Guard
- Defined in:
- lib/net.rb
Constant Summary collapse
- @@mutex =
Mutex.new
- @@registered =
false
- @@conns =
Set.new
Class Method Summary collapse
Class Method Details
.register(conn) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/net.rb', line 21 def self.register(conn) @@mutex.synchronize { if !@@registered @@registered = true EM.add_shutdown_hook { EM_Guard.remove_em_waiters } end @@conns += [conn] } end |
.remove_em_waiters ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/net.rb', line 37 def self.remove_em_waiters old_conns = Set.new @@mutex.synchronize { @@registered = false @@conns, old_conns = old_conns, @@conns } # This function acquires `@mon` on the connections, so it's # safer to do this outside our own synchronization. old_conns.each {|conn| conn.remove_em_waiters } end |
.unregister(conn) ⇒ Object
32 33 34 35 36 |
# File 'lib/net.rb', line 32 def self.unregister(conn) @@mutex.synchronize { @@conns -= [conn] } end |