Sha256: 36e24d7fb4943f448136116536d5e0fd5fa9b8fea4e78adf7951347d130d5df7

Contents?: true

Size: 579 Bytes

Versions: 7

Compression:

Stored size: 579 Bytes

Contents

# frozen_string_literal: true

# wat.rb
require 'async'
require_relative '../../lib/async/io'
require 'digest/sha1'
require 'securerandom'

Async.run do |task|
	r, w = IO.pipe.map { |io| Async::IO.try_convert(io) }

	task.async do |subtask|
		s = Digest::SHA1.new
		l = 0
		100.times do
			bytes = SecureRandom.bytes(4000)
			s << bytes
			w << bytes
			l += bytes.bytesize
		end
		w.close
		p [:write, l, s.hexdigest]
	end
	
	task.async do |subtask|
		s = Digest::SHA1.new
		l = 0
		while b = r.read(4096)
			s << b
			l += b.bytesize
		end
		p [:read, l, s.hexdigest]
	end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
async-io-1.29.0 examples/issues/pipes.rb
async-io-1.28.0 examples/issues/pipes.rb
async-io-1.27.7 examples/issues/pipes.rb
async-io-1.27.6 examples/issues/pipes.rb
async-io-1.27.5 examples/issues/pipes.rb
async-io-1.27.4 examples/issues/pipes.rb
async-io-1.27.3 examples/issues/pipes.rb