Module: BitGirder::Concurrent::EmUtils
- Extended by:
- BitGirder::Core::BitGirderMethods
- Defined in:
- lib/bitgirder/concurrent.rb
Constant Summary collapse
- @@did_require =
false
Constants included from BitGirder::Core::BitGirderMethods
BitGirder::Core::BitGirderMethods::PARAM_TYPE_ARG, BitGirder::Core::BitGirderMethods::PARAM_TYPE_ENVVAR, BitGirder::Core::BitGirderMethods::PARAM_TYPE_KEY
Class Method Summary collapse
Methods included from BitGirder::Core::BitGirderMethods
argv_to_argh, check_fail_prefix, class_name_to_sym, code, compares_to, console, ext_to_class_name, ext_to_sym, has_env, has_key, has_keys, nonnegative, not_nil, positive, raisef, set_from_key, set_var, split_argv, sym_to_cli_switch, sym_to_ext_id, to_bool, unpack_argv_array, unpack_argv_hash, warn
Class Method Details
.defer(callback, &blk) ⇒ Object
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/bitgirder/concurrent.rb', line 377 def defer( callback, &blk ) ensure_em not_nil( callback, :callback ) raise "Need an operation block" unless blk op = lambda do begin Completion.create_success( blk.call ) rescue Exception => e Completion.create_failure( e ) end end EM.defer( op, callback ) end |
.ensure_em ⇒ Object
370 371 372 373 374 375 |
# File 'lib/bitgirder/concurrent.rb', line 370 def self.ensure_em unless @@did_require Concurrent.require_em @@did_require = true end end |