Class: CallingFunction
- Inherits:
-
Object
- Object
- CallingFunction
- Extended by:
- Forwardable
- Includes:
- MemberNames
- Defined in:
- ext/generate_gvl_code.rb
Overview
the zkrb_call_zoo_* function
Constant Summary collapse
- PREFIX =
'zkrb_call'
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#struct ⇒ Object
readonly
Returns the value of attribute struct.
-
#wrapper_fn ⇒ Object
readonly
Returns the value of attribute wrapper_fn.
-
#zoo_fn_name ⇒ Object
readonly
Returns the value of attribute zoo_fn_name.
Instance Method Summary collapse
- #body ⇒ Object
- #bottom ⇒ Object
- #fn_signature ⇒ Object
-
#initialize(zoo_fn_name, struct, wrapper_fn) ⇒ CallingFunction
constructor
A new instance of CallingFunction.
- #initializer_lines ⇒ Object
- #rb_thread_blocking_region_call ⇒ Object
- #top ⇒ Object
Methods included from MemberNames
Constructor Details
#initialize(zoo_fn_name, struct, wrapper_fn) ⇒ CallingFunction
Returns a new instance of CallingFunction.
143 144 145 146 147 |
# File 'ext/generate_gvl_code.rb', line 143 def initialize(zoo_fn_name, struct, wrapper_fn) @zoo_fn_name, @struct, @wrapper_fn = zoo_fn_name, struct, wrapper_fn @name = "#{PREFIX}_#{zoo_fn_name}" end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
141 142 143 |
# File 'ext/generate_gvl_code.rb', line 141 def name @name end |
#struct ⇒ Object (readonly)
Returns the value of attribute struct.
141 142 143 |
# File 'ext/generate_gvl_code.rb', line 141 def struct @struct end |
#wrapper_fn ⇒ Object (readonly)
Returns the value of attribute wrapper_fn.
141 142 143 |
# File 'ext/generate_gvl_code.rb', line 141 def wrapper_fn @wrapper_fn end |
#zoo_fn_name ⇒ Object (readonly)
Returns the value of attribute zoo_fn_name.
141 142 143 |
# File 'ext/generate_gvl_code.rb', line 141 def zoo_fn_name @zoo_fn_name end |
Instance Method Details
#body ⇒ Object
180 181 182 |
# File 'ext/generate_gvl_code.rb', line 180 def body @body ||= [top, rb_thread_blocking_region_call, bottom].join("\n") end |
#bottom ⇒ Object
172 173 174 175 176 177 178 |
# File 'ext/generate_gvl_code.rb', line 172 def bottom <<-EOS return args.rc; } EOS end |
#fn_signature ⇒ Object
149 150 151 |
# File 'ext/generate_gvl_code.rb', line 149 def fn_signature @fn_signature ||= "int #{name}(#{typed_args.join(', ')})" end |
#initializer_lines ⇒ Object
153 154 155 |
# File 'ext/generate_gvl_code.rb', line 153 def initializer_lines @initializer_lines ||= member_names.map { |n| " .#{n} = #{n}" }.join(",\n") end |
#rb_thread_blocking_region_call ⇒ Object
168 169 170 |
# File 'ext/generate_gvl_code.rb', line 168 def rb_thread_blocking_region_call " zkrb_thread_blocking_region(#{wrapper_fn.name}, (void *)&args);" end |
#top ⇒ Object
157 158 159 160 161 162 163 164 165 166 |
# File 'ext/generate_gvl_code.rb', line 157 def top <<-EOS // wrapper that calls #{zoo_fn_name} via #{wrapper_fn.name} inside rb_thread_blocking_region #{fn_signature} { #{struct.name} args = { .rc = ZKRB_FAIL, #{initializer_lines} }; EOS end |