ilios 0.4.8 → 0.4.9

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: c54ed7ca20c4e0633a57b33b41cbe2a8a9fe1c89134d92496fea61c1b5d6d0bb
4
- data.tar.gz: dbde2f3d25981a52980fb9eaf198c90aea663f1cd99b33923227ccb2fb0d76f4
3
+ metadata.gz: fe04ef9746b0a963eade104e22e4285eac2a5192fbb19407c6d5373d0b69e9e0
4
+ data.tar.gz: 66b83da5d0da081c2f737e7ce03ea4c878f62e28dfc6fc8816bece5d10ef941e
5
5
  SHA512:
6
- metadata.gz: 2db32fe42576c2a1add3b44903c2e4b93b163f240b5adc668ecbc18ea44f1611d007737657798e11e06125e8eda86a92994716b1b6ce74231a4c6d14d901f3f9
7
- data.tar.gz: ea74e0a82689fdae39a2924c1c5feccf1a334588eb239d0bddbc0878e4811b703cc53e2c6d873a26c8c8e05b9529a1280ffc07eabd025a96a860b01a9ec6a43f
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
@@ -195,31 +195,12 @@ VALUE future_create(CassFuture *future, VALUE session, future_kind kind)
195
195
  return cassandra_future_obj;
196
196
  }
197
197
 
198
- /**
199
- * Run block when future resolves to a value.
200
- *
201
- * @yieldparam value [Cassandra::Statement, Cassandra::Result] A value.
202
- * Yields +Cassandra::Statement+ object when future was created by +Cassandra::Session#prepare_async+.
203
- * Yields +Cassandra::Result+ object when future was created by +Cassandra::Session#execute_async+.
204
- * @return [Cassandra::Future] self.
205
- * @raise [Cassandra::ExecutionError] If this method will be called twice.
206
- * @raise [ArgumentError] If no block was given.
207
- */
208
- static VALUE future_on_success(VALUE self)
198
+ static VALUE future_on_success_synchronize(VALUE future)
209
199
  {
210
200
  CassandraFuture *cassandra_future;
211
201
  bool wakeup_thread = false;
212
202
 
213
- GET_FUTURE(self, cassandra_future);
214
-
215
- if (cassandra_future->on_success_block) {
216
- rb_raise(eExecutionError, "It should not call twice");
217
- }
218
- if (!rb_block_given_p()) {
219
- rb_raise(rb_eArgError, "no block given");
220
- }
221
-
222
- rb_mutex_lock(cassandra_future->proc_mutex);
203
+ GET_FUTURE(future, cassandra_future);
223
204
 
224
205
  if (!cassandra_future->on_failure_block) {
225
206
  // Invoke the callback with thread pool only once
@@ -229,44 +210,52 @@ static VALUE future_on_success(VALUE self)
229
210
  cassandra_future->on_success_block = rb_block_proc();
230
211
 
231
212
  if (cass_future_ready(cassandra_future->future)) {
232
- rb_mutex_unlock(cassandra_future->proc_mutex);
233
213
  uv_sem_post(&cassandra_future->sem);
234
214
  if (cass_future_error_code(cassandra_future->future) == CASS_OK) {
235
215
  future_result_success_yield(cassandra_future);
236
216
  }
237
- return self;
217
+ return future;
238
218
  }
239
219
 
240
220
  if (wakeup_thread) {
241
- future_queue_push(future_thread_pool_get(cassandra_future), self);
221
+ future_queue_push(future_thread_pool_get(cassandra_future), future);
242
222
  }
243
- rb_mutex_unlock(cassandra_future->proc_mutex);
244
223
 
245
- return self;
224
+ return future;
246
225
  }
247
226
 
248
227
  /**
249
- * Run block when future resolves to error.
228
+ * Run block when future resolves to a value.
250
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+.
251
233
  * @return [Cassandra::Future] self.
252
234
  * @raise [Cassandra::ExecutionError] If this method will be called twice.
253
235
  * @raise [ArgumentError] If no block was given.
254
236
  */
255
- static VALUE future_on_failure(VALUE self)
237
+ static VALUE future_on_success(VALUE self)
256
238
  {
257
239
  CassandraFuture *cassandra_future;
258
- bool wakeup_thread = false;
259
240
 
260
241
  GET_FUTURE(self, cassandra_future);
261
242
 
262
- if (cassandra_future->on_failure_block) {
243
+ if (cassandra_future->on_success_block) {
263
244
  rb_raise(eExecutionError, "It should not call twice");
264
245
  }
265
246
  if (!rb_block_given_p()) {
266
247
  rb_raise(rb_eArgError, "no block given");
267
248
  }
268
249
 
269
- 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);
270
259
 
271
260
  if (!cassandra_future->on_success_block) {
272
261
  // Invoke the callback with thread pool only once
@@ -276,20 +265,41 @@ static VALUE future_on_failure(VALUE self)
276
265
  cassandra_future->on_failure_block = rb_block_proc();
277
266
 
278
267
  if (cass_future_ready(cassandra_future->future)) {
279
- rb_mutex_unlock(cassandra_future->proc_mutex);
280
268
  uv_sem_post(&cassandra_future->sem);
281
269
  if (cass_future_error_code(cassandra_future->future) != CASS_OK) {
282
270
  future_result_failure_yield(cassandra_future);
283
271
  }
284
- return self;
272
+ return future;
285
273
  }
286
274
 
287
275
  if (wakeup_thread) {
288
- future_queue_push(future_thread_pool_get(cassandra_future), self);
276
+ future_queue_push(future_thread_pool_get(cassandra_future), future);
289
277
  }
290
- rb_mutex_unlock(cassandra_future->proc_mutex);
291
278
 
292
- 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);
293
303
  }
294
304
 
295
305
  /**
@@ -303,16 +313,18 @@ static VALUE future_await(VALUE self)
303
313
 
304
314
  GET_FUTURE(self, cassandra_future);
305
315
 
316
+ rb_mutex_lock(cassandra_future->proc_mutex);
306
317
  if (cassandra_future->already_waited) {
318
+ rb_mutex_unlock(cassandra_future->proc_mutex);
307
319
  return self;
308
320
  }
321
+ cassandra_future->already_waited = true;
322
+ rb_mutex_unlock(cassandra_future->proc_mutex);
309
323
 
324
+ nogvl_future_wait(cassandra_future->future);
310
325
  if (cassandra_future->on_success_block || cassandra_future->on_failure_block) {
311
326
  nogvl_sem_wait(&cassandra_future->sem);
312
- } else {
313
- nogvl_future_wait(cassandra_future->future);
314
327
  }
315
- cassandra_future->already_waited = true;
316
328
  return self;
317
329
  }
318
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.8'
4
+ VERSION = '0.4.9'
5
5
  public_constant :VERSION
6
6
 
7
7
  CASSANDRA_CPP_DRIVER_VERSION = '2.17.1'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ilios
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Watson
@@ -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.8
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: []