rage-iodine 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4221fdb6705dce60cb5e71da2644f639200571f690930fb9c428e29c4ae20032
4
- data.tar.gz: c01222eb2a55634b414c456d46319e5d2072a2ed89b258e709ea1d236cf490b9
3
+ metadata.gz: 14c91b97e06b90b30b47238df8eae6e431b1046bffb61758855a4a6f2fc647a4
4
+ data.tar.gz: 284676ad696fca697d05a8ac7e0d4f8159f6bf4d34105efea653fa07cc705f19
5
5
  SHA512:
6
- metadata.gz: ad43ae3016c28c794926b71fd62b4f48c1362c7865f8c0118b8b5548ded1885b28c198a9d93f87a387873b4451b9f7310b545ba079cc26708521dc8c47497f7e
7
- data.tar.gz: 0067566c6d7495bc2cc4652f49278d1eaa22f5afd9764cb84b654c44fd2483f7f14ccdcddd656b4ec529ad43c4d285ba8452976b075551c9683651ace0704a5a
6
+ metadata.gz: 5872a3cc209c22c85e6185a28e4a10dc5692426181766685580af260502dd09e6ff17f119b924a588d4a11a62c4e9a116e49640910219f4adf477e69914da590
7
+ data.tar.gz: 748d34cfcf129ecdbcd0cc3c00c72f0ece4c3e18703478d3f503448955915a4577720e70d33c2e39eafd8f52ca9c80d154986fae477b5ffbe56745bacaac2347
@@ -2,6 +2,7 @@
2
2
  #include "iodine_store.h"
3
3
  #include "ruby.h"
4
4
 
5
+ #include <errno.h>
5
6
  #include <stddef.h>
6
7
  #include <stdint.h>
7
8
  #include <stdio.h>
@@ -14,6 +15,7 @@
14
15
  static ID call_id;
15
16
  static uint8_t ATTACH_ON_READ_READY_CALLBACK;
16
17
  static uint8_t ATTACH_ON_WRITE_READY_CALLBACK;
18
+ static VALUE timeout_args[1];
17
19
 
18
20
  /* *****************************************************************************
19
21
  Fiber Scheduler API
@@ -27,6 +29,7 @@ static void noop(intptr_t uuid, fio_protocol_s *protocol) {
27
29
  typedef struct {
28
30
  fio_protocol_s p;
29
31
  VALUE block;
32
+ uint8_t fulfilled;
30
33
  } scheduler_protocol_s;
31
34
 
32
35
 
@@ -42,10 +45,20 @@ static void iodine_scheduler_task_close(intptr_t uuid, fio_protocol_s *fio_proto
42
45
  static void iodine_scheduler_task_perform(intptr_t uuid, fio_protocol_s *fio_protocol) {
43
46
  scheduler_protocol_s *protocol = (scheduler_protocol_s *)fio_protocol;
44
47
  IodineCaller.call(protocol->block, call_id);
48
+ protocol->fulfilled = 1;
45
49
 
46
50
  (void)uuid;
47
51
  }
48
52
 
53
+ static void iodine_scheduler_task_timeout(intptr_t uuid, fio_protocol_s *fio_protocol) {
54
+ scheduler_protocol_s *protocol = (scheduler_protocol_s *)fio_protocol;
55
+
56
+ if (!protocol->fulfilled) {
57
+ IodineCaller.call2(protocol->block, call_id, 1, timeout_args);
58
+ fio_close(uuid);
59
+ }
60
+ }
61
+
49
62
  static VALUE iodine_scheduler_attach(VALUE self, VALUE r_fd, VALUE r_waittype, VALUE r_timeout) {
50
63
  Check_Type(r_fd, T_FIXNUM);
51
64
  int fd = FIX2INT(r_fd);
@@ -69,7 +82,7 @@ static VALUE iodine_scheduler_attach(VALUE self, VALUE r_fd, VALUE r_waittype, V
69
82
  .p.on_data = iodine_scheduler_task_perform,
70
83
  .p.on_ready = iodine_scheduler_task_perform,
71
84
  .p.on_close = iodine_scheduler_task_close,
72
- .p.ping = noop,
85
+ .p.ping = iodine_scheduler_task_timeout,
73
86
  .block = block,
74
87
  };
75
88
  } else if (waittype & ATTACH_ON_READ_READY_CALLBACK) {
@@ -77,7 +90,7 @@ static VALUE iodine_scheduler_attach(VALUE self, VALUE r_fd, VALUE r_waittype, V
77
90
  .p.on_data = iodine_scheduler_task_perform,
78
91
  .p.on_ready = noop,
79
92
  .p.on_close = iodine_scheduler_task_close,
80
- .p.ping = noop,
93
+ .p.ping = iodine_scheduler_task_timeout,
81
94
  .block = block,
82
95
  };
83
96
  } else if (waittype & ATTACH_ON_WRITE_READY_CALLBACK) {
@@ -85,7 +98,7 @@ static VALUE iodine_scheduler_attach(VALUE self, VALUE r_fd, VALUE r_waittype, V
85
98
  .p.on_data = noop,
86
99
  .p.on_ready = iodine_scheduler_task_perform,
87
100
  .p.on_close = iodine_scheduler_task_close,
88
- .p.ping = noop,
101
+ .p.ping = iodine_scheduler_task_timeout,
89
102
  .block = block,
90
103
  };
91
104
  }
@@ -161,6 +174,7 @@ Scheduler initialization
161
174
 
162
175
  void iodine_scheduler_initialize(void) {
163
176
  call_id = rb_intern2("call", 4);
177
+ timeout_args[0] = UINT2NUM(ETIMEDOUT);
164
178
 
165
179
  VALUE SchedulerModule = rb_define_module_under(IodineModule, "Scheduler");
166
180
 
@@ -1,3 +1,3 @@
1
1
  module Iodine
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rage-iodine
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boaz Segev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-31 00:00:00.000000000 Z
11
+ date: 2023-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake