io-event 1.14.0 → 1.14.2
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 +18 -5
- 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: 0deb2b3991062957f5767ac97e9abf7fe72b20e2264d08fd81293c407f92024f
|
|
4
|
+
data.tar.gz: 93b9e08ea55f39b5b983b8627b91720047154a2f778d86fea620da54d5e3173c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e58ec44e475bad561ddd53797a1552037fc92a4602dd89f6af92148130d4486d7dca47b6ae09bf11373be7e393a1baea835ae29e3ea388da4d4189b1d87be47
|
|
7
|
+
data.tar.gz: 9040993cc15180b65f142a28529d6672dceb88de0ae887ca9f1815bf0e11d4fe7929a3295ec50110b6c7faab83728cf36bf5c51d564b377eca4af40b756e9140
|
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,12 +212,12 @@ 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) {
|
|
215
|
+
static int create_worker_thread(VALUE self, struct IO_Event_WorkerPool *pool) {
|
|
203
216
|
if (pool->current_worker_count >= pool->maximum_worker_count) {
|
|
204
217
|
return -1;
|
|
205
218
|
}
|
|
206
219
|
|
|
207
|
-
|
|
220
|
+
struct IO_Event_WorkerPool_Worker *worker = malloc(sizeof(struct IO_Event_WorkerPool_Worker));
|
|
208
221
|
if (!worker) {
|
|
209
222
|
return -1;
|
|
210
223
|
}
|
|
@@ -214,7 +227,7 @@ static int create_worker_thread(struct IO_Event_WorkerPool *pool) {
|
|
|
214
227
|
worker->current_blocking_operation = NULL;
|
|
215
228
|
worker->next = pool->workers;
|
|
216
229
|
|
|
217
|
-
worker->thread
|
|
230
|
+
RB_OBJ_WRITE(self, &worker->thread, rb_thread_create(worker_thread_func, worker));
|
|
218
231
|
if (NIL_P(worker->thread)) {
|
|
219
232
|
free(worker);
|
|
220
233
|
return -1;
|
|
@@ -273,7 +286,7 @@ static VALUE worker_pool_initialize(int argc, VALUE *argv, VALUE self) {
|
|
|
273
286
|
|
|
274
287
|
// Create initial workers
|
|
275
288
|
for (size_t i = 0; i < maximum_worker_count; i++) {
|
|
276
|
-
if (create_worker_thread(pool) != 0) {
|
|
289
|
+
if (create_worker_thread(self, pool) != 0) {
|
|
277
290
|
// Just set the maximum_worker_count for debugging, don't fail completely
|
|
278
291
|
// worker_pool_free(pool);
|
|
279
292
|
// 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.2
|
|
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
|