Sha256: 7f3d6db655ad4396a083d0699fadafc01000003643beb152428908fd00fe0973

Contents?: true

Size: 1.1 KB

Versions: 22

Compression:

Stored size: 1.1 KB

Contents

require 'libuv'

describe Libuv::Accessors do
    describe 'basic usage' do
        it 'should work seamlessly with the default thread' do
            count = 0
            reactor do |reactor|
                reactor.timer {
                    count += 1
                    reactor.stop if count == 3
                }.start(50, 10)
            end

            expect(count).to eq(3)
        end

        it 'work simply with new threads' do
            count = 0
            sig = ConditionVariable.new
            mutex = Mutex.new
            mutex.synchronize {

                # This will run on a new thread
                Libuv::Reactor.new do |reactor|
                    reactor.timer {
                        count += 1

                        if count == 3
                            reactor.stop
                            mutex.synchronize {
                                sig.signal
                            }
                        end
                    }.start(50, 10)
                end

                sig.wait(mutex)
            }

            expect(count).to eq(3)
        end
    end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
libuv-4.0.9 spec/dsl_spec.rb
libuv-4.0.2 spec/dsl_spec.rb
libuv-4.0.1 spec/dsl_spec.rb
libuv-4.0.0 spec/dsl_spec.rb
libuv-3.3.0 spec/dsl_spec.rb
libuv-3.2.4 spec/dsl_spec.rb
libuv-3.2.3 spec/dsl_spec.rb
libuv-3.2.2 spec/dsl_spec.rb
libuv-3.2.1 spec/dsl_spec.rb
libuv-3.2.0 spec/dsl_spec.rb
libuv-3.1.9 spec/dsl_spec.rb
libuv-3.1.8 spec/dsl_spec.rb
libuv-3.1.7 spec/dsl_spec.rb
libuv-3.1.6 spec/dsl_spec.rb
libuv-3.1.5 spec/dsl_spec.rb
libuv-3.1.4 spec/dsl_spec.rb
libuv-3.1.3 spec/dsl_spec.rb
libuv-3.1.2 spec/dsl_spec.rb
libuv-3.1.1 spec/dsl_spec.rb
libuv-3.1.0 spec/dsl_spec.rb