io-event 1.14.0 → 1.14.1
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ext/io/event/worker_pool.c +29 -18
- data/lib/io/event/version.rb +1 -1
- data/releases.md +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5db83dbc5cd7f63abe723a5ddd79821592d47090ece9c0c940f539550ec3b84e
|
|
4
|
+
data.tar.gz: 9e15a94bd293c8af581e58d5178ffaace83aa52c93b5aaf5a2e2aca34e4e136d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 219307268126c7d27129722c34e1b1f5572683f6cdad99425449573045b9591de3b926bc4bd510208584e149b1e94a8cc15cd5c5739d3d141e8d55ef12964a83
|
|
7
|
+
data.tar.gz: 07d411e20aca99e29344bb113da4f849d5093ee3ed6b6785460bc4b6fe2d7ee298b4c0e9147b6cffce919088c7367c5298c6e1d5704ca795dc98af9e22740f32
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/ext/io/event/worker_pool.c
CHANGED
|
@@ -86,6 +86,19 @@ static void worker_pool_free(void *ptr) {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
static void worker_pool_mark(void *ptr)
|
|
90
|
+
{
|
|
91
|
+
struct IO_Event_WorkerPool *pool = (struct IO_Event_WorkerPool *)ptr;
|
|
92
|
+
struct IO_Event_WorkerPool_Worker *worker = pool->workers;
|
|
93
|
+
while (worker) {
|
|
94
|
+
struct IO_Event_WorkerPool_Worker *next = worker->next;
|
|
95
|
+
// We need to mark the thread even though its marked through the VM's ractors because we call `join`
|
|
96
|
+
// on them after their completion. They could be freed by then.
|
|
97
|
+
rb_gc_mark(worker->thread); // thread objects are currently pinned anyway
|
|
98
|
+
worker = next;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
89
102
|
// Size functions for Ruby GC
|
|
90
103
|
static size_t worker_pool_size(const void *ptr) {
|
|
91
104
|
return sizeof(struct IO_Event_WorkerPool);
|
|
@@ -94,7 +107,7 @@ static size_t worker_pool_size(const void *ptr) {
|
|
|
94
107
|
// Ruby TypedData structures
|
|
95
108
|
static const rb_data_type_t IO_Event_WorkerPool_type = {
|
|
96
109
|
"IO::Event::WorkerPool",
|
|
97
|
-
{
|
|
110
|
+
{worker_pool_mark, worker_pool_free, worker_pool_size,},
|
|
98
111
|
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
|
|
99
112
|
};
|
|
100
113
|
|
|
@@ -199,22 +212,20 @@ static VALUE worker_thread_func(void *_worker) {
|
|
|
199
212
|
}
|
|
200
213
|
|
|
201
214
|
// Create a new worker thread
|
|
202
|
-
static int create_worker_thread(struct IO_Event_WorkerPool *pool) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
worker->
|
|
216
|
-
|
|
217
|
-
worker->thread = rb_thread_create(worker_thread_func, worker);
|
|
215
|
+
static int create_worker_thread(VALUE self, struct IO_Event_WorkerPool *pool) {
|
|
216
|
+
if (pool->current_worker_count >= pool->maximum_worker_count) {
|
|
217
|
+
return -1;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
struct IO_Event_WorkerPool_Worker *worker = malloc(sizeof(struct IO_Event_WorkerPool_Worker));
|
|
221
|
+
if (!worker) {
|
|
222
|
+
return -1;
|
|
223
|
+
}
|
|
224
|
+
@@ -214,7 +227,7 @@ static int create_worker_thread(struct IO_Event_WorkerPool *pool) {
|
|
225
|
+
worker->current_blocking_operation = NULL;
|
|
226
|
+
worker->next = pool->workers;
|
|
227
|
+
|
|
228
|
+
RB_OBJ_WRITE(self, &worker->thread, rb_thread_create(worker_thread_func, worker));
|
|
218
229
|
if (NIL_P(worker->thread)) {
|
|
219
230
|
free(worker);
|
|
220
231
|
return -1;
|
|
@@ -273,7 +284,7 @@ static VALUE worker_pool_initialize(int argc, VALUE *argv, VALUE self) {
|
|
|
273
284
|
|
|
274
285
|
// Create initial workers
|
|
275
286
|
for (size_t i = 0; i < maximum_worker_count; i++) {
|
|
276
|
-
if (create_worker_thread(pool) != 0) {
|
|
287
|
+
if (create_worker_thread(self, pool) != 0) {
|
|
277
288
|
// Just set the maximum_worker_count for debugging, don't fail completely
|
|
278
289
|
// worker_pool_free(pool);
|
|
279
290
|
// rb_raise(rb_eRuntimeError, "Failed to create workers");
|
data/lib/io/event/version.rb
CHANGED
data/releases.md
CHANGED
|
@@ -22,7 +22,7 @@ heap.concat([5, 2, 8, 1, 9, 3])
|
|
|
22
22
|
removed = heap.delete(5) # Returns 5, heap maintains order
|
|
23
23
|
|
|
24
24
|
# Bulk removal with condition
|
|
25
|
-
count = heap.delete_if
|
|
25
|
+
count = heap.delete_if{|x| x.even?} # Removes 2, 8 efficiently
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
The `delete_if` and `concat` methods are particularly efficient for bulk operations, using bottom-up heapification to maintain the heap property in O(n) time. This provides significant performance improvements:
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: io-event
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.14.
|
|
4
|
+
version: 1.14.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
116
116
|
- !ruby/object:Gem::Version
|
|
117
117
|
version: '0'
|
|
118
118
|
requirements: []
|
|
119
|
-
rubygems_version: 3.
|
|
119
|
+
rubygems_version: 3.6.9
|
|
120
120
|
specification_version: 4
|
|
121
121
|
summary: An event loop.
|
|
122
122
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|