Skip to content

Instantly share code, notes, and snippets.

@masuidrive
Created October 21, 2012 13:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masuidrive/3926970 to your computer and use it in GitHub Desktop.
Save masuidrive/3926970 to your computer and use it in GitHub Desktop.
mruby thread proposal
# It's running on sub thread
# it isn't sharing with rubyvm_proposal1.rb's VM.
$action1_result = 0
def action1a
$action1_result
end
def action1b
$action1_result = 1
end
# create new VM on new thread
vm = CFunc::RubyVM.thread('rubyvm1')
# call action1a on new VM and thread
# sync call has blocking. it has result value
assert_equal 0, vm.dispatch_sync(:action1a)
# it's async call and non-blocking. it doesn't have result value
vm.dispatch_async :action1
assert_equal 1, vm.dispatch_sync(:action1a)
@masuidrive
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment