mt-libuv 4.1.03 → 4.1.04

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1202ed78ce77bd07568e4227426d50e6fbe0699900c2146890f75151d3c69a0
4
- data.tar.gz: 9aa062a9eaf012254125890a37b8dce64b6dbb36afee563f9c9c0c61040db31f
3
+ metadata.gz: 97df55146f5e23cd5d57ffa0da3bbaeac6696dc4a58ce16dc25e6ee7f5bcba33
4
+ data.tar.gz: afdee9a6c8931a23f1502cc3230e7568d656c76dddbdcb1c06282d7f2ad89f03
5
5
  SHA512:
6
- metadata.gz: 2f0461eaec6df22b89e63af45508401530d1a9bd341113edfbfc0aa2e50239c879dee658fe0d4f22a2499c1ed5db76324ae379b02cad8d3a46a00d4e5fb29591
7
- data.tar.gz: 9865e4c1eefebdc94a5d8366912f474615b2face27804c067f4cf190acf9edbaefc42b2eceeb7579d8c1179f2a2e465295a46ebe6cc9d2e9307d846262d945b8
6
+ metadata.gz: 68ecec179df4e06cab307e199251eef2b793ea2de12c7a115bf4e69d126c443f24bf1c5661db4869543503f3b24fb5f660ea32fadaaa21ca3d7c362944e63656
7
+ data.tar.gz: 1395844a001326ee85942b11631e117693e177031b95ad2d374cff4516c60cc0990ac61c00706728dd647ba432fb402d4e6d1527212c7b0787e6dea373bba72e
@@ -13,7 +13,7 @@ module MTLibuv
13
13
  # @param *promises [::MTLibuv::Q::Promise] a number of promises that will be combined into a single promise
14
14
  # @return [Object] Returns the result of a single promise or an array of results if provided multiple promises
15
15
  # @raise [Exception] if the promise is rejected
16
- def co(*yieldable)
16
+ def co(*yieldable, &block)
17
17
  on_reactor = MTLibuv::Reactor.current
18
18
  raise 'must be running on a reactor thread to use coroutines' unless on_reactor
19
19
 
@@ -24,7 +24,7 @@ module MTLibuv
24
24
  if yieldable.length == 1
25
25
  promise = yieldable[0]
26
26
  # Passed independently as this is often overwritten for performance
27
- promise.progress &Proc.new if block_given?
27
+ promise.progress &block if block_given?
28
28
  else
29
29
  promise = on_reactor.all(*yieldable)
30
30
  end
data/lib/mt-libuv/file.rb CHANGED
@@ -29,7 +29,7 @@ module MTLibuv
29
29
  attr_reader :fileno, :closed
30
30
 
31
31
 
32
- def initialize(thread, path, flags = 0, mode: 0)
32
+ def initialize(thread, path, flags = 0, mode: 0, &block)
33
33
  super(thread, thread.defer)
34
34
 
35
35
  @fileno = -1
@@ -41,7 +41,7 @@ module MTLibuv
41
41
  pre_check @defer, request, ::MTLibuv::Ext.fs_open(@reactor, request, @path, @flags, @mode, callback(:on_open, request.address))
42
42
 
43
43
  if block_given?
44
- self.progress &Proc.new
44
+ self.progress &block
45
45
  else
46
46
  @coroutine = @reactor.defer
47
47
  @coroutine.promise.value
data/lib/mt-libuv/pipe.rb CHANGED
@@ -59,7 +59,7 @@ module MTLibuv
59
59
  self
60
60
  end
61
61
 
62
- def connect(name)
62
+ def connect(name, &block)
63
63
  return if @closed
64
64
  assert_type(String, name, "name must be a String")
65
65
 
@@ -72,7 +72,7 @@ module MTLibuv
72
72
  end
73
73
 
74
74
  if block_given?
75
- @callback = Proc.new
75
+ @callback = block
76
76
  else
77
77
  @coroutine = @reactor.defer
78
78
  @coroutine.promise.value
data/lib/mt-libuv/q.rb CHANGED
@@ -104,9 +104,9 @@ module MTLibuv
104
104
  #
105
105
  # @param [Proc, Proc, Proc, &blk] callbacks error, success, progress, success_block
106
106
  # @return [Promise] Returns an unresolved promise for chaining
107
- def then(callback = nil, errback = nil, progback = nil)
107
+ def then(callback = nil, errback = nil, progback = nil, &block)
108
108
  result = Q.defer(@reactor)
109
- callback = Proc.new if block_given?
109
+ callback = block if block_given?
110
110
 
111
111
  wrappedCallback = proc { |val|
112
112
  begin
@@ -182,9 +182,9 @@ module MTLibuv
182
182
  @response = response
183
183
  end
184
184
 
185
- def then(callback = nil, errback = nil, progback = nil)
185
+ def then(callback = nil, errback = nil, progback = nil, &block)
186
186
  result = Q.defer(@reactor)
187
- callback = Proc.new if block_given?
187
+ callback = block if block_given?
188
188
 
189
189
  @reactor.next_tick {
190
190
  if @error
@@ -236,9 +236,9 @@ module MTLibuv
236
236
  # Provides a promise notifier for receiving un-handled exceptions
237
237
  #
238
238
  # @return [::MTLibuv::Q::Promise]
239
- def notifier
239
+ def notifier(&block)
240
240
  @reactor_notify = if block_given?
241
- Proc.new
241
+ block
242
242
  else
243
243
  @reactor_notify_default
244
244
  end
@@ -373,27 +373,27 @@ module MTLibuv
373
373
  #
374
374
  # @param callback [Proc] the callback to be called on timer trigger
375
375
  # @return [::MTLibuv::Timer]
376
- def timer
376
+ def timer(&block)
377
377
  handle = Timer.new(@reactor)
378
- handle.progress &Proc.new if block_given?
378
+ handle.progress &block if block_given?
379
379
  handle
380
380
  end
381
381
 
382
382
  # Get a new Prepare handle
383
383
  #
384
384
  # @return [::MTLibuv::Prepare]
385
- def prepare
385
+ def prepare(&block)
386
386
  handle = Prepare.new(@reactor)
387
- handle.progress &Proc.new if block_given?
387
+ handle.progress &block if block_given?
388
388
  handle
389
389
  end
390
390
 
391
391
  # Get a new Check handle
392
392
  #
393
393
  # @return [::MTLibuv::Check]
394
- def check
394
+ def check(&block)
395
395
  handle = Check.new(@reactor)
396
- handle.progress &Proc.new if block_given?
396
+ handle.progress &block if block_given?
397
397
  handle
398
398
  end
399
399
 
@@ -401,27 +401,27 @@ module MTLibuv
401
401
  #
402
402
  # @param callback [Proc] the callback to be called on idle trigger
403
403
  # @return [::MTLibuv::Idle]
404
- def idle
404
+ def idle(&block)
405
405
  handle = Idle.new(@reactor)
406
- handle.progress &Proc.new if block_given?
406
+ handle.progress &block if block_given?
407
407
  handle
408
408
  end
409
409
 
410
410
  # Get a new Async handle
411
411
  #
412
412
  # @return [::MTLibuv::Async]
413
- def async
413
+ def async(&block)
414
414
  handle = Async.new(@reactor)
415
- handle.progress &Proc.new if block_given?
415
+ handle.progress &block if block_given?
416
416
  handle
417
417
  end
418
418
 
419
419
  # Get a new signal handler
420
420
  #
421
421
  # @return [::MTLibuv::Signal]
422
- def signal(signum = nil)
422
+ def signal(signum = nil, &block)
423
423
  handle = Signal.new(@reactor)
424
- handle.progress &Proc.new if block_given?
424
+ handle.progress &block if block_given?
425
425
  handle.start(signum) if signum
426
426
  handle
427
427
  end
@@ -458,12 +458,12 @@ module MTLibuv
458
458
  # @param port [Integer, String] the service being connected too
459
459
  # @param callback [Proc] the callback to be called on success
460
460
  # @return [::MTLibuv::Dns]
461
- def lookup(hostname, hint = :IPv4, port = 9, wait: true)
461
+ def lookup(hostname, hint = :IPv4, port = 9, wait: true, &block)
462
462
  dns = Dns.new(@reactor, hostname, port, hint, wait: wait) # Work is a promise object
463
463
  if wait
464
464
  dns.results
465
465
  else
466
- dns.then &Proc.new if block_given?
466
+ dns.then &block if block_given?
467
467
  dns
468
468
  end
469
469
  end
@@ -505,11 +505,11 @@ module MTLibuv
505
505
  # Schedule some work to be processed on the event reactor as soon as possible (thread safe)
506
506
  #
507
507
  # @yield the callback to be called on the reactor thread
508
- def schedule
508
+ def schedule(&block)
509
509
  if reactor_thread?
510
510
  yield
511
511
  else
512
- @run_queue << Proc.new
512
+ @run_queue << block
513
513
  @process_queue.call
514
514
  end
515
515
  self
data/lib/mt-libuv/tcp.rb CHANGED
@@ -252,11 +252,11 @@ module MTLibuv
252
252
  def open(fd, binding = true)
253
253
  return self if @closed
254
254
 
255
- if binding
255
+ if binding(&block)
256
256
  @on_listen = proc { accept }
257
- @on_accept = Proc.new
257
+ @on_accept = block
258
258
  elsif block_given?
259
- @callback = Proc.new
259
+ @callback = block
260
260
  else
261
261
  @coroutine = @reactor.defer
262
262
  end
@@ -267,7 +267,7 @@ module MTLibuv
267
267
  self
268
268
  end
269
269
 
270
- def connect(ip, port)
270
+ def connect(ip, port, &block)
271
271
  return self if @closed
272
272
 
273
273
  assert_type(String, ip, IP_ARGUMENT_ERROR)
@@ -281,7 +281,7 @@ module MTLibuv
281
281
  end
282
282
 
283
283
  if block_given?
284
- @callback = Proc.new
284
+ @callback = block
285
285
  else
286
286
  @coroutine = @reactor.defer
287
287
  @coroutine.promise.value
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MTLibuv
4
- VERSION = '4.1.03'
4
+ VERSION = '4.1.04'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mt-libuv
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.03
4
+ version: 4.1.04
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giallombardo Nathan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-25 00:00:00.000000000 Z
11
+ date: 2022-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi