Class: Hakuban::ObjectExpose
- Inherits:
-
Object
- Object
- Hakuban::ObjectExpose
- Defined in:
- lib/hakuban/hakuban.rb,
lib/hakuban/manager.rb
Defined Under Namespace
Classes: ManagedObject
Instance Attribute Summary collapse
-
#descriptor ⇒ Object
readonly
Returns the value of attribute descriptor.
Instance Method Summary collapse
- #assigned? ⇒ Boolean
- #assignment ⇒ Object
- #desynchronize(assignment) ⇒ Object
- #drop ⇒ Object
- #dropped? ⇒ Boolean
-
#initialize(local_node, descriptor, serializer) ⇒ ObjectExpose
constructor
A new instance of ObjectExpose.
- #inspect ⇒ Object
- #manage ⇒ Object
- #new_callback_event_queue ⇒ Object
- #new_event_queue ⇒ Object
- #set_object_state(version, data, data_type: [], assignment: 0) ⇒ Object
Constructor Details
#initialize(local_node, descriptor, serializer) ⇒ ObjectExpose
Returns a new instance of ObjectExpose.
279 280 281 282 283 284 285 |
# File 'lib/hakuban/hakuban.rb', line 279 def initialize(local_node, descriptor, serializer) @local_node, @descriptor, @serializer = local_node, descriptor, serializer result = FFI::hakuban_object_expose_new(@local_node.local_node_pointer, descriptor.to_ffi) Hakuban::raise_if_error(result) @queues = [] @object_expose_pointer = ::FFI::AutoPointer.new(result[:object_expose_pointer], FFI::method(:hakuban_object_expose_drop)) end |
Instance Attribute Details
#descriptor ⇒ Object (readonly)
Returns the value of attribute descriptor.
277 278 279 |
# File 'lib/hakuban/hakuban.rb', line 277 def descriptor @descriptor end |
Instance Method Details
#assigned? ⇒ Boolean
300 301 302 |
# File 'lib/hakuban/hakuban.rb', line 300 def assigned? assignment > 0 end |
#assignment ⇒ Object
295 296 297 298 |
# File 'lib/hakuban/hakuban.rb', line 295 def assignment raise "Attempt to use after 'drop'" if not @object_expose_pointer FFI::hakuban_object_expose_assignment(@object_expose_pointer) end |
#desynchronize(assignment) ⇒ Object
304 305 306 307 |
# File 'lib/hakuban/hakuban.rb', line 304 def desynchronize(assignment) raise "Attempt to use after 'drop'" if not @object_expose_pointer FFI::hakuban_object_expose_desynchronize(@object_expose_pointer, assignment) end |
#drop ⇒ Object
325 326 327 328 329 |
# File 'lib/hakuban/hakuban.rb', line 325 def drop @object_expose_pointer.free @object_expose_pointer = nil @queues.each(&:close) #is this atomic? @queues.clear end |
#dropped? ⇒ Boolean
331 332 333 |
# File 'lib/hakuban/hakuban.rb', line 331 def dropped? @object_expose_pointer.nil? end |
#inspect ⇒ Object
321 322 323 |
# File 'lib/hakuban/hakuban.rb', line 321 def inspect "#<ObjectExpose #{@descriptor}>" end |
#manage ⇒ Object
307 308 309 |
# File 'lib/hakuban/manager.rb', line 307 def manage ObjectManagerBuilder.new(self) end |
#new_callback_event_queue ⇒ Object
309 310 311 312 |
# File 'lib/hakuban/hakuban.rb', line 309 def new_callback_event_queue raise "Attempt to use after 'drop'" if not @object_expose_pointer ObjectDescriptorCallbackEventQueue.new(FFI::hakuban_object_expose_events_get(@object_expose_pointer)) end |
#new_event_queue ⇒ Object
314 315 316 317 318 319 |
# File 'lib/hakuban/hakuban.rb', line 314 def new_event_queue raise "Attempt to use after 'drop'" if not @object_expose_pointer queue = ObjectDescriptorEventQueue.new(self) @queues << queue queue end |
#set_object_state(version, data, data_type: [], assignment: 0) ⇒ Object
287 288 289 290 291 292 293 |
# File 'lib/hakuban/hakuban.rb', line 287 def set_object_state(version, data, data_type: [], assignment: 0) raise "Attempt to use after 'drop'" if not @object_expose_pointer serialized_data_type, serialized_data = @serializer.call(data_type, data) result = FFI::hakuban_object_expose_state(@object_expose_pointer, FFI::FFIObjectExposeState.construct(version, serialized_data_type, serialized_data), assignment) Hakuban::raise_if_error(result) result[:changed] == 1 end |