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.
141 142 143 144 145 |
# File 'ext/generate_gvl_code.rb', line 141 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.
139 140 141 |
# File 'ext/generate_gvl_code.rb', line 139 def name @name end |
#struct ⇒ Object (readonly)
Returns the value of attribute struct.
139 140 141 |
# File 'ext/generate_gvl_code.rb', line 139 def struct @struct end |
#wrapper_fn ⇒ Object (readonly)
Returns the value of attribute wrapper_fn.
139 140 141 |
# File 'ext/generate_gvl_code.rb', line 139 def wrapper_fn @wrapper_fn end |
#zoo_fn_name ⇒ Object (readonly)
Returns the value of attribute zoo_fn_name.
139 140 141 |
# File 'ext/generate_gvl_code.rb', line 139 def zoo_fn_name @zoo_fn_name end |
Instance Method Details
#body ⇒ Object
178 179 180 |
# File 'ext/generate_gvl_code.rb', line 178 def body @body ||= [top, rb_thread_blocking_region_call, bottom].join("\n") end |
#bottom ⇒ Object
170 171 172 173 174 175 176 |
# File 'ext/generate_gvl_code.rb', line 170 def bottom <<-EOS return args.rc; } EOS end |
#fn_signature ⇒ Object
147 148 149 |
# File 'ext/generate_gvl_code.rb', line 147 def fn_signature @fn_signature ||= "int #{name}(#{typed_args.join(', ')})" end |
#initializer_lines ⇒ Object
151 152 153 |
# File 'ext/generate_gvl_code.rb', line 151 def initializer_lines @initializer_lines ||= member_names.map { |n| " .#{n} = #{n}" }.join(",\n") end |
#rb_thread_blocking_region_call ⇒ Object
166 167 168 |
# File 'ext/generate_gvl_code.rb', line 166 def rb_thread_blocking_region_call " zkrb_thread_blocking_region(#{wrapper_fn.name}, (void *)&args);" end |
#top ⇒ Object
155 156 157 158 159 160 161 162 163 164 |
# File 'ext/generate_gvl_code.rb', line 155 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 |