ilios 0.4.7 → 0.4.9

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: 7794c439a6a3b6c6f0362b2b1d4b20b553727473320921d6c370a524e6863c39
4
- data.tar.gz: 8d01681e24c7b822f3a4e96837f4682cbb139527c1660a1d2db7371ff9cba551
3
+ metadata.gz: fe04ef9746b0a963eade104e22e4285eac2a5192fbb19407c6d5373d0b69e9e0
4
+ data.tar.gz: 66b83da5d0da081c2f737e7ce03ea4c878f62e28dfc6fc8816bece5d10ef941e
5
5
  SHA512:
6
- metadata.gz: 7b2e96c2adcf02b602ba9e97d2ba25bbecd3816106519ab3b61e97f814df033f01650bbd2a99fc9b7475f26e2cc598c6a864b1098215a9742be65ee80a3695ad
7
- data.tar.gz: 3d5ca806b3f682fe2427e3f3cd091ceacd8a98e5894479ddf6bd5cbcb721f58ca4e64cb4a2e3e318b7aff36ed09a851791d04403cc185d4f03adbefeb045c385
6
+ metadata.gz: ac26a4ed1f5f37807161acde7fbb62f2268f0e81b9d81b3412eb151650ad830cf38fbdb3283b67251c8aba526d56781b4ee4419e5ebb98a7459e6cfab5f39606
7
+ data.tar.gz: 93a3620eea6b6af5982d0805d36350100d93340353e0ea0681bdfb4043dbfa59cdf8e4267c12989ef9620f9da99fca73b1a8d21fc412609054220bf696cdb4f0
data/docker-compose.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  version: '3'
2
2
  services:
3
3
  cassandra:
4
- image: cassandra:5
4
+ image: cassandra:4
5
5
  ports:
6
6
  - 9042:9042
7
7
  volumes:
data/ext/ilios/future.c CHANGED
@@ -140,6 +140,7 @@ static VALUE future_result_yielder_synchronize(VALUE future)
140
140
  } else {
141
141
  future_result_failure_yield(cassandra_future);
142
142
  }
143
+ cassandra_future->already_waited = true;
143
144
  return Qnil;
144
145
  }
145
146
 
@@ -194,31 +195,12 @@ VALUE future_create(CassFuture *future, VALUE session, future_kind kind)
194
195
  return cassandra_future_obj;
195
196
  }
196
197
 
197
- /**
198
- * Run block when future resolves to a value.
199
- *
200
- * @yieldparam value [Cassandra::Statement, Cassandra::Result] A value.
201
- * Yields +Cassandra::Statement+ object when future was created by +Cassandra::Session#prepare_async+.
202
- * Yields +Cassandra::Result+ object when future was created by +Cassandra::Session#execute_async+.
203
- * @return [Cassandra::Future] self.
204
- * @raise [Cassandra::ExecutionError] If this method will be called twice.
205
- * @raise [ArgumentError] If no block was given.
206
- */
207
- static VALUE future_on_success(VALUE self)
198
+ static VALUE future_on_success_synchronize(VALUE future)
208
199
  {
209
200
  CassandraFuture *cassandra_future;
210
201
  bool wakeup_thread = false;
211
202
 
212
- GET_FUTURE(self, cassandra_future);
213
-
214
- if (cassandra_future->on_success_block) {
215
- rb_raise(eExecutionError, "It should not call twice");
216
- }
217
- if (!rb_block_given_p()) {
218
- rb_raise(rb_eArgError, "no block given");
219
- }
220
-
221
- rb_mutex_lock(cassandra_future->proc_mutex);
203
+ GET_FUTURE(future, cassandra_future);
222
204
 
223
205
  if (!cassandra_future->on_failure_block) {
224
206
  // Invoke the callback with thread pool only once
@@ -228,44 +210,52 @@ static VALUE future_on_success(VALUE self)
228
210
  cassandra_future->on_success_block = rb_block_proc();
229
211
 
230
212
  if (cass_future_ready(cassandra_future->future)) {
231
- rb_mutex_unlock(cassandra_future->proc_mutex);
232
213
  uv_sem_post(&cassandra_future->sem);
233
214
  if (cass_future_error_code(cassandra_future->future) == CASS_OK) {
234
215
  future_result_success_yield(cassandra_future);
235
216
  }
236
- return self;
217
+ return future;
237
218
  }
238
219
 
239
220
  if (wakeup_thread) {
240
- future_queue_push(future_thread_pool_get(cassandra_future), self);
221
+ future_queue_push(future_thread_pool_get(cassandra_future), future);
241
222
  }
242
- rb_mutex_unlock(cassandra_future->proc_mutex);
243
223
 
244
- return self;
224
+ return future;
245
225
  }
246
226
 
247
227
  /**
248
- * Run block when future resolves to error.
228
+ * Run block when future resolves to a value.
249
229
  *
230
+ * @yieldparam value [Cassandra::Statement, Cassandra::Result] A value.
231
+ * Yields +Cassandra::Statement+ object when future was created by +Cassandra::Session#prepare_async+.
232
+ * Yields +Cassandra::Result+ object when future was created by +Cassandra::Session#execute_async+.
250
233
  * @return [Cassandra::Future] self.
251
234
  * @raise [Cassandra::ExecutionError] If this method will be called twice.
252
235
  * @raise [ArgumentError] If no block was given.
253
236
  */
254
- static VALUE future_on_failure(VALUE self)
237
+ static VALUE future_on_success(VALUE self)
255
238
  {
256
239
  CassandraFuture *cassandra_future;
257
- bool wakeup_thread = false;
258
240
 
259
241
  GET_FUTURE(self, cassandra_future);
260
242
 
261
- if (cassandra_future->on_failure_block) {
243
+ if (cassandra_future->on_success_block) {
262
244
  rb_raise(eExecutionError, "It should not call twice");
263
245
  }
264
246
  if (!rb_block_given_p()) {
265
247
  rb_raise(rb_eArgError, "no block given");
266
248
  }
267
249
 
268
- rb_mutex_lock(cassandra_future->proc_mutex);
250
+ return rb_mutex_synchronize(cassandra_future->proc_mutex, future_on_success_synchronize, self);
251
+ }
252
+
253
+ static VALUE future_on_failure_synchronize(VALUE future)
254
+ {
255
+ CassandraFuture *cassandra_future;
256
+ bool wakeup_thread = false;
257
+
258
+ GET_FUTURE(future, cassandra_future);
269
259
 
270
260
  if (!cassandra_future->on_success_block) {
271
261
  // Invoke the callback with thread pool only once
@@ -275,20 +265,41 @@ static VALUE future_on_failure(VALUE self)
275
265
  cassandra_future->on_failure_block = rb_block_proc();
276
266
 
277
267
  if (cass_future_ready(cassandra_future->future)) {
278
- rb_mutex_unlock(cassandra_future->proc_mutex);
279
268
  uv_sem_post(&cassandra_future->sem);
280
269
  if (cass_future_error_code(cassandra_future->future) != CASS_OK) {
281
270
  future_result_failure_yield(cassandra_future);
282
271
  }
283
- return self;
272
+ return future;
284
273
  }
285
274
 
286
275
  if (wakeup_thread) {
287
- future_queue_push(future_thread_pool_get(cassandra_future), self);
276
+ future_queue_push(future_thread_pool_get(cassandra_future), future);
288
277
  }
289
- rb_mutex_unlock(cassandra_future->proc_mutex);
290
278
 
291
- return self;
279
+ return future;
280
+ }
281
+
282
+ /**
283
+ * Run block when future resolves to error.
284
+ *
285
+ * @return [Cassandra::Future] self.
286
+ * @raise [Cassandra::ExecutionError] If this method will be called twice.
287
+ * @raise [ArgumentError] If no block was given.
288
+ */
289
+ static VALUE future_on_failure(VALUE self)
290
+ {
291
+ CassandraFuture *cassandra_future;
292
+
293
+ GET_FUTURE(self, cassandra_future);
294
+
295
+ if (cassandra_future->on_failure_block) {
296
+ rb_raise(eExecutionError, "It should not call twice");
297
+ }
298
+ if (!rb_block_given_p()) {
299
+ rb_raise(rb_eArgError, "no block given");
300
+ }
301
+
302
+ return rb_mutex_synchronize(cassandra_future->proc_mutex, future_on_failure_synchronize, self);
292
303
  }
293
304
 
294
305
  /**
@@ -302,16 +313,18 @@ static VALUE future_await(VALUE self)
302
313
 
303
314
  GET_FUTURE(self, cassandra_future);
304
315
 
316
+ rb_mutex_lock(cassandra_future->proc_mutex);
305
317
  if (cassandra_future->already_waited) {
318
+ rb_mutex_unlock(cassandra_future->proc_mutex);
306
319
  return self;
307
320
  }
321
+ cassandra_future->already_waited = true;
322
+ rb_mutex_unlock(cassandra_future->proc_mutex);
308
323
 
324
+ nogvl_future_wait(cassandra_future->future);
309
325
  if (cassandra_future->on_success_block || cassandra_future->on_failure_block) {
310
326
  nogvl_sem_wait(&cassandra_future->sem);
311
- } else {
312
- nogvl_future_wait(cassandra_future->future);
313
327
  }
314
- cassandra_future->already_waited = true;
315
328
  return self;
316
329
  }
317
330
 
data/lib/ilios/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ilios
4
- VERSION = '0.4.7'
4
+ VERSION = '0.4.9'
5
5
  public_constant :VERSION
6
6
 
7
7
  CASSANDRA_CPP_DRIVER_VERSION = '2.17.1'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ilios
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Watson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-08 00:00:00.000000000 Z
11
+ date: 2024-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_portile2
@@ -77,7 +77,7 @@ metadata:
77
77
  homepage_uri: https://github.com/Watson1978/ilios
78
78
  source_code_uri: https://github.com/Watson1978/ilios
79
79
  bug_tracker_uri: https://github.com/Watson1978/ilios/issues
80
- documentation_uri: https://www.rubydoc.info/gems/ilios/0.4.7
80
+ documentation_uri: https://www.rubydoc.info/gems/ilios/0.4.9
81
81
  rubygems_mfa_required: 'true'
82
82
  post_install_message:
83
83
  rdoc_options: []