65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/neo4j_bolt.rb', line 65
def cleanup
if Thread.current.thread_variable_get(LEASE_KEY).to_i.positive?
raise Error, "cleanup_neo4j cannot run while this thread is using Neo4j"
end
driver = nil
cleanup_started = false
mutex.synchronize do
condition.wait(mutex) while @closing
@closing = true
cleanup_started = true
condition.wait(mutex) until leases.zero?
driver = @driver
@driver = nil
end
driver&.close
ensure
if cleanup_started
mutex.synchronize do
@closing = false
condition.broadcast
end
end
end
|