Class: Ilios::Cassandra::Future
- Inherits:
-
Object
- Object
- Ilios::Cassandra::Future
- Defined in:
- ext/ilios/ilios.c
Instance Method Summary collapse
-
#await ⇒ Cassandra::Future
Wait to complete a future’s statement.
-
#on_failure ⇒ Cassandra::Future
Run block when future resolves to error.
-
#on_success {|value| ... } ⇒ Cassandra::Future
Run block when future resolves to a value.
Instance Method Details
#await ⇒ Cassandra::Future
Wait to complete a future’s statement.
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'ext/ilios/future.c', line 311
static VALUE future_await(VALUE self)
{
CassandraFuture *cassandra_future;
GET_FUTURE(self, cassandra_future);
rb_mutex_lock(cassandra_future->proc_mutex);
if (cassandra_future->already_waited) {
rb_mutex_unlock(cassandra_future->proc_mutex);
return self;
}
cassandra_future->already_waited = true;
rb_mutex_unlock(cassandra_future->proc_mutex);
nogvl_future_wait(cassandra_future->future);
if (cassandra_future->on_success_block || cassandra_future->on_failure_block) {
nogvl_sem_wait(&cassandra_future->sem);
}
return self;
}
|
#on_failure ⇒ Cassandra::Future
Run block when future resolves to error.
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'ext/ilios/future.c', line 290
static VALUE future_on_failure(VALUE self)
{
CassandraFuture *cassandra_future;
GET_FUTURE(self, cassandra_future);
if (cassandra_future->on_failure_block) {
rb_raise(eExecutionError, "It should not call twice");
}
if (!rb_block_given_p()) {
rb_raise(rb_eArgError, "no block given");
}
return rb_mutex_synchronize(cassandra_future->proc_mutex, future_on_failure_synchronize, self);
}
|
#on_success {|value| ... } ⇒ Cassandra::Future
Run block when future resolves to a value.
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'ext/ilios/future.c', line 238
static VALUE future_on_success(VALUE self)
{
CassandraFuture *cassandra_future;
GET_FUTURE(self, cassandra_future);
if (cassandra_future->on_success_block) {
rb_raise(eExecutionError, "It should not call twice");
}
if (!rb_block_given_p()) {
rb_raise(rb_eArgError, "no block given");
}
return rb_mutex_synchronize(cassandra_future->proc_mutex, future_on_success_synchronize, self);
}
|