io-event 1.2.1 → 1.2.3

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: 02cbd4beff5335467997d91cbdc8e3bbf509947a15e2f36636b3e4e29b7cd91e
4
- data.tar.gz: 9ca1138136d115d1fdfd4e41446f6f7b684de878ec6a7834f27a9ea6ba210896
3
+ metadata.gz: 41757dbe8c584fbdf66a0d7adb6b4e7f3ab377aed137c65b49eed48e7ff1d223
4
+ data.tar.gz: 84672d42c12a9db38d901a7f4ab4d8f3d74bc98d398fb615d95c6780533bb2bb
5
5
  SHA512:
6
- metadata.gz: 5fe958c76100f346101702b285b140bebe3a149525288cf8e83a1a1806a710928627e8c2d5ae4d8ec716836c264d6f645daa77b944ce1d59a5aaef6ac572e7aa
7
- data.tar.gz: 9ce5953f7c6c3fba1e41e61fcc4ae7e24a294624a004fc532724fd49c707afc14a837359547df45611e0df6ab35e9d954e6f8e09eed748c845ad6ed8a6b61076
6
+ metadata.gz: 2d32bce07ae295fecd57c67920ec2c0f3796313d80154179290116eb8ad8fd3b58e440c5531a23186bb9cfe2dfdd87fccd709742742559d8d151ae9b0cdb1419
7
+ data.tar.gz: e6a6476decc497fab325b047ec7c90c235e505356cf07e145c5ed9e00443b9273743a8180c6e12e5a2d496b8e8d4b42a781438e175d3768f3d6f86ce3b84c9fc
checksums.yaml.gz.sig CHANGED
Binary file
data/ext/extconf.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # Released under the MIT License.
5
- # Copyright, 2021, by Samuel Williams.
5
+ # Copyright, 2021-2023, by Samuel Williams.
6
6
 
7
7
  # Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
8
8
  #
@@ -27,7 +27,7 @@ struct IO_Event_Interrupt {
27
27
  int descriptor;
28
28
  };
29
29
 
30
- inline int IO_Event_Interrupt_descriptor(struct IO_Event_Interrupt *interrupt) {
30
+ static inline int IO_Event_Interrupt_descriptor(struct IO_Event_Interrupt *interrupt) {
31
31
  return interrupt->descriptor;
32
32
  }
33
33
  #else
@@ -35,7 +35,7 @@ struct IO_Event_Interrupt {
35
35
  int descriptor[2];
36
36
  };
37
37
 
38
- inline int IO_Event_Interrupt_descriptor(struct IO_Event_Interrupt *interrupt) {
38
+ static inline int IO_Event_Interrupt_descriptor(struct IO_Event_Interrupt *interrupt) {
39
39
  return interrupt->descriptor[0];
40
40
  }
41
41
  #endif
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  module IO::Event
7
7
  # A thread safe synchronisation primative.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2022, by Samuel Williams.
4
+ # Copyright, 2022-2023, by Samuel Williams.
5
5
 
6
6
  require 'io/nonblock'
7
7
 
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
+ # Copyright, 2023, by Math Ieu.
5
6
 
6
7
  require_relative '../interrupt'
7
8
  require_relative '../support'
@@ -103,14 +104,26 @@ module IO::Event
103
104
  self.fiber&.alive?
104
105
  end
105
106
 
106
- def transfer(events)
107
+ # Dispatch the given events to the list of waiting fibers. If the fiber was not waiting for the given events, it is reactivated by calling the given block.
108
+ def dispatch(events, &reactivate)
109
+ # We capture the tail here, because calling reactivate might modify it:
110
+ tail = self.tail
111
+
107
112
  if fiber = self.fiber
108
- self.fiber = nil
109
-
110
- fiber.transfer(events & self.events) if fiber.alive?
113
+ if fiber.alive?
114
+ revents = events & self.events
115
+ if revents.zero?
116
+ reactivate.call(self)
117
+ else
118
+ self.fiber = nil
119
+ fiber.transfer(revents)
120
+ end
121
+ else
122
+ self.fiber = nil
123
+ end
111
124
  end
112
-
113
- self.tail&.transfer(events)
125
+
126
+ tail&.dispatch(events, &reactivate)
114
127
  end
115
128
 
116
129
  def invalidate
@@ -349,7 +362,11 @@ module IO::Event
349
362
  end
350
363
 
351
364
  ready.each do |io, events|
352
- @waiting.delete(io).transfer(events)
365
+ @waiting.delete(io).dispatch(events) do |waiter|
366
+ # Re-schedule the waiting IO:
367
+ waiter.tail = @waiting[io]
368
+ @waiting[io] = waiter
369
+ end
353
370
  end
354
371
 
355
372
  return ready.size
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  class IO
7
7
  module Event
8
- VERSION = "1.2.1"
8
+ VERSION = "1.2.3"
9
9
  end
10
10
  end
data/lib/io/event.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'event/version'
7
7
  require_relative 'event/selector'
data/license.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2021-2022, by Samuel Williams.
3
+ Copyright, 2021-2023, by Samuel Williams.
4
4
  Copyright, 2021, by Delton Ding.
5
5
  Copyright, 2021, by Benoit Daloze.
6
6
  Copyright, 2022, by Alex Matchneer.
7
7
  Copyright, 2022, by Bruno Sutic.
8
+ Copyright, 2023, by Math Ieu.
8
9
 
9
10
  Permission is hereby granted, free of charge, to any person obtaining a copy
10
11
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -16,8 +16,16 @@ Please see the [project documentation](https://socketry.github.io/io-event/).
16
16
 
17
17
  We welcome contributions to this project.
18
18
 
19
- 1. Fork it
20
- 2. Create your feature branch (`git checkout -b my-new-feature`)
21
- 3. Commit your changes (`git commit -am 'Add some feature'`)
22
- 4. Push to the branch (`git push origin my-new-feature`)
23
- 5. Create new Pull Request
19
+ 1. Fork it.
20
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
21
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
22
+ 4. Push to the branch (`git push origin my-new-feature`).
23
+ 5. Create new Pull Request.
24
+
25
+ ### Developer Certificate of Origin
26
+
27
+ This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
28
+
29
+ ### Contributor Covenant
30
+
31
+ This project is governed by [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: io-event
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  - Bruno Sutic
9
+ - Math Ieu
10
+ - Alex Matchneer
9
11
  - Benoit Daloze
10
12
  - Delton Ding
11
- - machty
12
13
  autorequire:
13
14
  bindir: bin
14
15
  cert_chain:
@@ -41,64 +42,8 @@ cert_chain:
41
42
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
42
43
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
43
44
  -----END CERTIFICATE-----
44
- date: 2023-05-13 00:00:00.000000000 Z
45
- dependencies:
46
- - !ruby/object:Gem::Dependency
47
- name: bake
48
- requirement: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: '0'
53
- type: :development
54
- prerelease: false
55
- version_requirements: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: '0'
60
- - !ruby/object:Gem::Dependency
61
- name: bundler
62
- requirement: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: '0'
67
- type: :development
68
- prerelease: false
69
- version_requirements: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: '0'
74
- - !ruby/object:Gem::Dependency
75
- name: covered
76
- requirement: !ruby/object:Gem::Requirement
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: '0'
81
- type: :development
82
- prerelease: false
83
- version_requirements: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
- - !ruby/object:Gem::Dependency
89
- name: sus
90
- requirement: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - "~>"
93
- - !ruby/object:Gem::Version
94
- version: '0.6'
95
- type: :development
96
- prerelease: false
97
- version_requirements: !ruby/object:Gem::Requirement
98
- requirements:
99
- - - "~>"
100
- - !ruby/object:Gem::Version
101
- version: '0.6'
45
+ date: 2023-07-26 00:00:00.000000000 Z
46
+ dependencies: []
102
47
  description:
103
48
  email:
104
49
  executables: []
@@ -150,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
95
  - !ruby/object:Gem::Version
151
96
  version: '0'
152
97
  requirements: []
153
- rubygems_version: 3.4.7
98
+ rubygems_version: 3.4.10
154
99
  signing_key:
155
100
  specification_version: 4
156
101
  summary: An event loop.
metadata.gz.sig CHANGED
Binary file