lib/logstash_writer.rb in logstash_writer-0.0.9 vs lib/logstash_writer.rb in logstash_writer-0.0.10

- old
+ new

@@ -92,11 +92,13 @@ @metrics[:lag].set({}, 0) @metrics[:queue_size].set({}, 0) metrics_registry.gauge(:"#{metrics_prefix}_queue_max", "The maximum size of the event queue").set({}, backlog) - @queue = [] + # We can't use a stdlib Queue object because we need to re-push items + # onto the front of the queue in case of error + @queue = [] @queue_mutex = Mutex.new @queue_cv = ConditionVariable.new @socket_mutex = Mutex.new @worker_mutex = Mutex.new @@ -142,15 +144,13 @@ # @return [NilClass] # def run @worker_mutex.synchronize do if @worker_thread.nil? - m, cv = Mutex.new, ConditionVariable.new - - @worker_thread = Thread.new { cv.signal; write_loop } - - # Don't return until the thread has *actually* started - m.synchronize { cv.wait(m) } + @worker_thread = Thread.new do + Thread.current.name = "LogstashWriter" + write_loop + end end end nil end