Class: Rubex::AST::Statement::NoGilBlock
- Defined in:
- lib/rubex/ast/statement/no_gil_block.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #analyse_statement(local_scope) ⇒ Object
- #generate_code(code, local_scope) ⇒ Object
-
#initialize(statements) ⇒ NoGilBlock
constructor
A new instance of NoGilBlock.
Methods inherited from Base
Constructor Details
#initialize(statements) ⇒ NoGilBlock
Returns a new instance of NoGilBlock.
5 6 7 |
# File 'lib/rubex/ast/statement/no_gil_block.rb', line 5 def initialize statements @statements = statements end |
Instance Method Details
#analyse_statement(local_scope) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/rubex/ast/statement/no_gil_block.rb', line 9 def analyse_statement(local_scope) local_scope.found_no_gil_block @block_scope = Rubex::SymbolTable::Scope::NoGilBlock.new( block_name(local_scope), local_scope) create_c_function_to_house_statements local_scope.outer_scope # TODO: check if ruby objects exist in the block. Raise error if yes. end |
#generate_code(code, local_scope) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/rubex/ast/statement/no_gil_block.rb', line 17 def generate_code(code, local_scope) code.nl code << "/* no_gil block: */" code.nl super cb_c_name = local_scope.find(@no_gil_func.name).c_name code << "rb_thread_call_without_gvl(#{cb_c_name}, NULL, RUBY_UBF_PROCESS, NULL);" code.nl end |