Sha256: 70774b74b9cc071c3296123e35907205ece4c9ec3e32def8641339a27fed0b8e

Contents?: true

Size: 643 Bytes

Versions: 4

Compression:

Stored size: 643 Bytes

Contents

module RedisRing

  module BackgroundThread

    def before_run
    end

    def after_halt
    end

    def do_work
    end

    def run
      before_run

      @continue_running = true

      return Thread.new do
        begin
          while continue_running?
            do_work
          end
          after_halt
        rescue SystemExit
          raise
        rescue => e
          puts "Error caught in #{self.class.name}:"
          puts e
          puts e.backtrace.join("\n")
        end
      end
    end

    def continue_running?
      @continue_running
    end

    def halt
      @continue_running = false
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
redis_ring-0.1.3 lib/redis_ring/background_thread.rb
redis_ring-0.1.2 lib/redis_ring/background_thread.rb
redis_ring-0.1.1 lib/redis_ring/background_thread.rb
redis_ring-0.1.0 lib/redis_ring/background_thread.rb