Created
October 21, 2012 13:38
-
-
Save masuidrive/3926970 to your computer and use it in GitHub Desktop.
mruby thread proposal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
references: