Sha256: 3f7e6f4a5a4d6398aa36ae91751793038a1363139f71204ca4346ddca11810e4

Contents?: true

Size: 695 Bytes

Versions: 3

Compression:

Stored size: 695 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "bario"
require "bario/cli"

require "optparse"

parser = OptionParser.new do |opts|
  opts.banner = "Usage: bario-demo [options]"
  Bario::CLI.common(opts)
end

parser.parse!

threads = []
3.times.each do |t1|
  bar = Bario::Bar.create(name: "bar #{t1}")
  threads << Thread.new do
    100.times do
      bar.increment
      sleep(1.0 / ((t1 + 1) * 2))
    end
    bar.delete
  end

  t1.times.each do |t2|
    child = bar.add_bar(name: "bar > #{t2}")
    threads << Thread.new do
      100.times do
        child.increment
        sleep(0.1)
      end
      child.delete
    end
  end
end

threads.map(&:join)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bario-0.1.2 bin/bario-demo
bario-0.1.1 bin/bario-demo
bario-0.1.0 bin/bario-demo