hakuban 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/hakuban-engine +10 -10
- data/bin/{hakuban-observer → hakuban-observe} +20 -27
- data/lib/hakuban/contract.rb +62 -110
- data/lib/hakuban/descriptor.rb +15 -20
- data/lib/hakuban/engine.rb +73 -29
- data/lib/hakuban/exchange.rb +73 -31
- data/lib/hakuban/ffi-object.rb +46 -55
- data/lib/hakuban/ffi.rb +76 -169
- data/lib/hakuban/logger.rb +2 -2
- data/lib/hakuban/object_state.rb +13 -14
- data/lib/hakuban/object_state_sink.rb +17 -25
- data/lib/hakuban/object_state_stream.rb +15 -15
- data/lib/hakuban/refinements.rb +23 -0
- data/lib/hakuban/stream.rb +160 -90
- data/lib/hakuban/tokio-websocket-connector.rb +12 -5
- data/lib/hakuban/version.rb +1 -1
- data/lib/hakuban.rb +1 -1
- metadata +16 -15
data/lib/hakuban/exchange.rb
CHANGED
@@ -3,73 +3,115 @@ require 'socket'
|
|
3
3
|
|
4
4
|
module Hakuban
|
5
5
|
|
6
|
-
class
|
6
|
+
class Exchange < FFIObject
|
7
7
|
|
8
|
-
def initialize(
|
8
|
+
def initialize(&block)
|
9
|
+
super()
|
9
10
|
Hakuban::hakuban_initialize
|
10
11
|
Hakuban::logger_initialize("hakuban=warn", skip_if_already_initialized: true)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
def self.default_name
|
18
|
-
"#{Socket.gethostname}:#{File.basename(caller_locations(0..1)[1].path)}:#{$$}"
|
12
|
+
Thread.handle_interrupt(Object => :never) {
|
13
|
+
pointer = FFI::hakuban_exchange_new().unwrap
|
14
|
+
initialize_pointer(pointer, :hakuban_exchange_drop, :hakuban_exchange_clone)
|
15
|
+
self.do_and_drop_or_return(&block)
|
16
|
+
}
|
19
17
|
end
|
20
18
|
|
21
19
|
public
|
22
20
|
|
23
|
-
def
|
21
|
+
def object_observe_contract(tags, descriptor=nil)
|
22
|
+
if tags.kind_of? ObjectDescriptor
|
23
|
+
ObjectObserveContractBuilder.new(self, tags)
|
24
|
+
else
|
25
|
+
ObjectObserveContractBuilder.new(self, ObjectDescriptor.new(tags, descriptor))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def object_expose_contract(tags, descriptor=nil)
|
24
30
|
if tags.kind_of? ObjectDescriptor
|
25
|
-
|
31
|
+
ObjectExposeContractBuilder.new(self, tags)
|
26
32
|
else
|
27
|
-
|
33
|
+
ObjectExposeContractBuilder.new(self, ObjectDescriptor.new(tags, descriptor))
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
31
|
-
def
|
37
|
+
def tag_observe_contract(descriptor)
|
32
38
|
if descriptor.kind_of? TagDescriptor
|
33
|
-
|
39
|
+
TagObserveContractBuilder.new(self, descriptor)
|
34
40
|
else
|
35
|
-
|
41
|
+
TagObserveContractBuilder.new(self, TagDescriptor.new(descriptor))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def tag_expose_contract(descriptor)
|
46
|
+
if descriptor.kind_of? TagDescriptor
|
47
|
+
TagExposeContractBuilder.new(self, descriptor)
|
48
|
+
else
|
49
|
+
TagExposeContractBuilder.new(self, TagDescriptor.new(descriptor))
|
36
50
|
end
|
37
51
|
end
|
38
52
|
|
39
53
|
end
|
40
54
|
|
41
55
|
|
42
|
-
class
|
56
|
+
class ObjectObserveContractBuilder
|
43
57
|
|
44
|
-
def initialize(
|
45
|
-
@
|
58
|
+
def initialize(exchange, descriptor)
|
59
|
+
@exchange, @descriptor = exchange, descriptor
|
46
60
|
end
|
47
61
|
|
48
|
-
def
|
49
|
-
ObjectObserveContract.send(:new, @
|
62
|
+
def build(&block)
|
63
|
+
ObjectObserveContract.send(:new, @exchange, @descriptor, &block)
|
50
64
|
end
|
51
65
|
|
52
|
-
|
53
|
-
|
66
|
+
end
|
67
|
+
|
68
|
+
class ObjectExposeContractBuilder
|
69
|
+
|
70
|
+
def initialize(exchange, descriptor)
|
71
|
+
@exchange, @descriptor = exchange, descriptor
|
72
|
+
@capacity = 1
|
73
|
+
end
|
74
|
+
|
75
|
+
def with_capacity(capacity)
|
76
|
+
@capacity = capacity
|
77
|
+
self
|
78
|
+
end
|
79
|
+
|
80
|
+
def build(&block)
|
81
|
+
ObjectExposeContract.send(:new, @exchange, @descriptor, @capacity, &block)
|
54
82
|
end
|
55
83
|
|
56
84
|
end
|
57
85
|
|
58
86
|
|
59
|
-
class
|
87
|
+
class TagObserveContractBuilder
|
60
88
|
|
61
|
-
def initialize(
|
62
|
-
@
|
89
|
+
def initialize(exchange, descriptor)
|
90
|
+
@exchange, @descriptor = exchange, descriptor
|
63
91
|
end
|
64
92
|
|
65
|
-
def
|
66
|
-
TagObserveContract.send(:new, @
|
93
|
+
def build(&block)
|
94
|
+
TagObserveContract.send(:new, @exchange, @descriptor, &block)
|
67
95
|
end
|
68
96
|
|
69
|
-
|
70
|
-
|
97
|
+
end
|
98
|
+
|
99
|
+
class TagExposeContractBuilder
|
100
|
+
|
101
|
+
def initialize(exchange, descriptor)
|
102
|
+
@exchange, @descriptor = exchange, descriptor
|
103
|
+
@capacity = 1
|
104
|
+
end
|
105
|
+
|
106
|
+
def with_capacity(capacity)
|
107
|
+
@capacity = capacity
|
108
|
+
self
|
109
|
+
end
|
110
|
+
|
111
|
+
def build(&block)
|
112
|
+
TagExposeContract.send(:new, @exchange, @descriptor, @capacity, &block)
|
71
113
|
end
|
72
114
|
|
73
115
|
end
|
74
|
-
|
116
|
+
|
75
117
|
end
|
data/lib/hakuban/ffi-object.rb
CHANGED
@@ -7,25 +7,40 @@ module Hakuban
|
|
7
7
|
|
8
8
|
class PointerAlreadyDropped < Exception; end
|
9
9
|
|
10
|
+
def initialize
|
11
|
+
@pointer_mutex = Mutex.new
|
12
|
+
end
|
13
|
+
|
14
|
+
private def initialize_from_ffi_pointer(pointer, drop_fn, clone_fn)
|
15
|
+
@pointer_mutex = Mutex.new
|
16
|
+
initialize_pointer(pointer, drop_fn, clone_fn)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def self.from_ffi_pointer(cls, pointer)
|
21
|
+
cls.allocate.tap { |new_instance| new_instance.initialize_from_ffi_pointer(pointer) }
|
22
|
+
end
|
23
|
+
|
10
24
|
private def initialize_pointer(pointer, drop_fn, clone_fn)
|
11
25
|
@pointer, @drop_fn, @clone_fn = pointer.address, drop_fn, clone_fn
|
12
|
-
@mutex ||= Mutex.new
|
13
|
-
@drop_requested = false
|
14
|
-
@drop_locked_by = Set.new
|
15
|
-
@drop_locked_by_condvar = nil
|
16
26
|
ObjectSpace.define_finalizer(self, FFIObject::generate_finalizer(drop_fn, @pointer))
|
17
27
|
end
|
18
|
-
|
28
|
+
|
19
29
|
|
20
30
|
def initialize_copy(original)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
31
|
+
Thread.handle_interrupt(Object => :never) {
|
32
|
+
if @clone_fn.nil?
|
33
|
+
@pointer_mutex.synchronize {
|
34
|
+
raise PointerAlreadyDropped if original.instance_variable_get(:@pointer).nil?
|
35
|
+
original.instance_variable_set(:@pointer, nil)
|
36
|
+
ObjectSpace.undefine_finalizer(original)
|
37
|
+
}
|
38
|
+
else
|
39
|
+
original.with_pointer { |pointer|
|
40
|
+
@pointer = FFI::method(@clone_fn).call(::FFI::Pointer.new(pointer)).address
|
41
|
+
}
|
42
|
+
end
|
43
|
+
@pointer_mutex = Mutex.new
|
29
44
|
ObjectSpace.undefine_finalizer(self)
|
30
45
|
ObjectSpace.define_finalizer(self, FFIObject::generate_finalizer(@drop_fn, @pointer))
|
31
46
|
}
|
@@ -33,9 +48,12 @@ module Hakuban
|
|
33
48
|
|
34
49
|
|
35
50
|
def with_pointer
|
36
|
-
@
|
37
|
-
|
38
|
-
|
51
|
+
@pointer_mutex.synchronize {
|
52
|
+
if @pointer
|
53
|
+
yield ::FFI::Pointer.new(@pointer)
|
54
|
+
else
|
55
|
+
raise PointerAlreadyDropped
|
56
|
+
end
|
39
57
|
}
|
40
58
|
end
|
41
59
|
|
@@ -57,40 +75,20 @@ module Hakuban
|
|
57
75
|
|
58
76
|
|
59
77
|
def drop
|
60
|
-
@
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
ObjectSpace.undefine_finalizer(self)
|
69
|
-
FFI::method(@drop_fn).call(::FFI::Pointer.new(@pointer))
|
70
|
-
@pointer = @finalizer = nil
|
71
|
-
}
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
def drop_lock(queue)
|
76
|
-
@mutex.synchronize {
|
77
|
-
raise FFIObject::PointerAlreadyDropped if @drop_requested
|
78
|
-
@drop_locked_by << queue
|
79
|
-
}
|
80
|
-
true
|
81
|
-
end
|
82
|
-
|
83
|
-
|
84
|
-
def drop_release(queue)
|
85
|
-
@mutex.synchronize {
|
86
|
-
@drop_locked_by.delete(queue)
|
87
|
-
@drop_locked_by_condvar.broadcast if @drop_locked_by_condvar
|
78
|
+
@pointer_mutex.synchronize {
|
79
|
+
Thread.handle_interrupt(Object => :never) {
|
80
|
+
if !!@pointer
|
81
|
+
ObjectSpace.undefine_finalizer(self)
|
82
|
+
FFI::method(@drop_fn).call(::FFI::Pointer.new(@pointer))
|
83
|
+
@pointer = nil
|
84
|
+
end
|
85
|
+
}
|
88
86
|
}
|
89
87
|
end
|
90
88
|
|
91
89
|
|
92
90
|
def dropped?
|
93
|
-
|
91
|
+
!@pointer
|
94
92
|
end
|
95
93
|
|
96
94
|
|
@@ -101,8 +99,9 @@ module Hakuban
|
|
101
99
|
end
|
102
100
|
|
103
101
|
|
104
|
-
|
105
|
-
|
102
|
+
# this should always be called with interrupts disabled, in the same section where pointer creation occurs
|
103
|
+
def do_and_drop_or_return(&block)
|
104
|
+
if block
|
106
105
|
begin
|
107
106
|
Thread.handle_interrupt(Object => :immediate) {
|
108
107
|
yield self
|
@@ -110,18 +109,10 @@ module Hakuban
|
|
110
109
|
ensure
|
111
110
|
self.drop
|
112
111
|
end
|
113
|
-
}
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
def do_and_drop_or_return(&block)
|
118
|
-
if block
|
119
|
-
do_and_drop(&block)
|
120
112
|
else
|
121
113
|
self
|
122
114
|
end
|
123
115
|
end
|
124
|
-
|
125
116
|
|
126
117
|
def inspect
|
127
118
|
"#<#{self.class.name} #{self.dropped? ? "DROPPED" : "%016X"%@pointer}>"
|
data/lib/hakuban/ffi.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'ffi'
|
3
3
|
require 'hakuban/ffi-object'
|
4
|
-
|
4
|
+
require 'hakuban/refinements'
|
5
5
|
|
6
6
|
module Hakuban::FFI
|
7
7
|
|
@@ -16,9 +16,10 @@ module Hakuban::FFI
|
|
16
16
|
class FFIErrorInvalidLogLevel < FFIError; end
|
17
17
|
class FFIErrorUnknownError < FFIError; end
|
18
18
|
|
19
|
+
|
19
20
|
class FFIResultStatus < FFI::Struct
|
20
21
|
layout :id, :uint8
|
21
|
-
ENUM = [:Ok, :Pending, :
|
22
|
+
ENUM = [:Ok, :Pointer, :Pending, :EndOfStream, :InvalidString, :InvalidJSON, :InvalidURL, :InvalidLogLevel, :LoggerInitializationError, :ConnectionTerminated].freeze
|
22
23
|
|
23
24
|
def to_sym
|
24
25
|
ENUM[self[:id]]
|
@@ -31,196 +32,99 @@ module Hakuban::FFI
|
|
31
32
|
|
32
33
|
|
33
34
|
class FFIResult < FFI::Struct
|
34
|
-
FFIResultStatus::ENUM.each { |sym|
|
35
|
-
define_method(("is_"+sym.to_s+"?").to_sym) {
|
36
|
-
FFIResultStatus::ENUM[self[:status][:id]] == sym
|
37
|
-
}
|
38
|
-
}
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
class FFIResultWithNothing < FFIResult
|
43
|
-
layout :status, FFIResultStatus
|
44
|
-
|
45
|
-
def unwrap
|
46
|
-
return nil if self[:status].to_sym == :NotAvailable
|
47
|
-
raise self[:status].to_exception if self[:status].to_sym != :Ok
|
48
|
-
nil
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
class FFIResultWithPointer < FFIResult
|
54
35
|
layout :status, FFIResultStatus, :pointer, :pointer
|
55
36
|
|
56
37
|
def unwrap
|
57
|
-
return
|
58
|
-
|
38
|
+
return true if self[:status].to_sym == :Ok
|
39
|
+
return nil if self[:status].to_sym == :EndOfStream
|
40
|
+
raise self[:status].to_exception if self[:status].to_sym != :Pointer
|
59
41
|
self[:pointer]
|
60
42
|
end
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
class Callbacks
|
65
|
-
|
66
|
-
attr_reader :waker
|
67
|
-
|
68
|
-
def initialize
|
69
|
-
@queues = {}
|
70
|
-
@queues_sequence = 0
|
71
|
-
@queues_mutex = Mutex.new
|
72
|
-
@waker = proc { |pointer|
|
73
|
-
queue_id = pointer.address
|
74
|
-
@queues_mutex.synchronize {
|
75
|
-
@queues[queue_id]&.each { |queue|
|
76
|
-
queue << :wake
|
77
|
-
}
|
78
|
-
}
|
79
|
-
}
|
80
|
-
end
|
81
|
-
|
82
|
-
def register_queue(queue)
|
83
|
-
@queues_mutex.synchronize {
|
84
|
-
@queues_sequence = (@queues_sequence+1) % 2**32
|
85
|
-
queue_id = @queues_sequence
|
86
|
-
(@queues[queue_id] ||= Set.new) << queue
|
87
|
-
queue_id
|
88
|
-
}
|
89
|
-
end
|
90
|
-
|
91
|
-
def unregister_queue(queue_id)
|
92
|
-
@queues_mutex.synchronize {
|
93
|
-
@queues[queue_id].delete(queue_id)
|
94
|
-
@queues.delete(queue_id) if @queues[queue_id].empty?
|
95
|
-
}
|
96
|
-
end
|
97
|
-
end
|
98
43
|
|
99
|
-
|
100
|
-
|
101
|
-
layout :pointer, :pointer
|
102
|
-
|
103
|
-
@@callbacks = Callbacks.new
|
104
|
-
|
105
|
-
def self.create_and_await(owner)
|
106
|
-
Thread.handle_interrupt(Object => :never) {
|
107
|
-
begin
|
108
|
-
queue = queue_id = drop_locked = pointer = nil
|
109
|
-
Thread.handle_interrupt(Object => :immediate) {
|
110
|
-
queue = Queue.new
|
111
|
-
queue_id = @@callbacks.register_queue(queue)
|
112
|
-
drop_locked = owner.drop_lock(queue)
|
113
|
-
return nil if !pointer = owner.with_pointer { |pointer| yield pointer }
|
114
|
-
loop {
|
115
|
-
result = owner.with_pointer { Hakuban::FFI::hakuban_future_returning_nothing_poll(pointer[:pointer],@@callbacks.waker,::FFI::Pointer.new(queue_id)) }
|
116
|
-
return result if not result.is_Pending?
|
117
|
-
# Currently the only future returning nothing is guaranteed to complete at first poll
|
118
|
-
# :unreachable:
|
119
|
-
raise Hakuban::FFIObject::PointerAlreadyDropped if queue.pop == :dropping
|
120
|
-
# :unreachable:
|
121
|
-
}
|
122
|
-
}
|
123
|
-
ensure
|
124
|
-
Hakuban::FFI::hakuban_future_returning_nothing_drop(pointer[:pointer]) if pointer
|
125
|
-
owner.drop_release(queue) if drop_locked
|
126
|
-
@@callbacks.unregister_queue(queue_id)
|
127
|
-
end
|
128
|
-
}
|
44
|
+
def status
|
45
|
+
self[:status].to_sym
|
129
46
|
end
|
130
47
|
end
|
131
48
|
|
132
49
|
|
133
|
-
class
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
@@callbacks.unregister_queue(queue_id)
|
157
|
-
end
|
158
|
-
}
|
50
|
+
class FFIFuture
|
51
|
+
|
52
|
+
using ThreadExt
|
53
|
+
|
54
|
+
#This HAS to be called with interrupts disabled.
|
55
|
+
#If both, internal exception, and an interrupt fire, pay attention not to drop one of them.
|
56
|
+
def self.await(future_pointer)
|
57
|
+
error = result_thread = result = nil
|
58
|
+
future_pointer_for_blocking_await = Hakuban::FFI::hakuban_future_clone(future_pointer)
|
59
|
+
begin
|
60
|
+
# ThreadError gets raised here on process shutdown
|
61
|
+
result_thread = Thread.new { Hakuban::FFI::hakuban_future_await(future_pointer_for_blocking_await) }
|
62
|
+
Thread.handle_interrupt(Object => :immediate) { result_thread.join }
|
63
|
+
rescue Object => e
|
64
|
+
error = e
|
65
|
+
end
|
66
|
+
Hakuban::FFI::hakuban_future_drop(future_pointer)
|
67
|
+
if result_thread
|
68
|
+
result = result_thread.join_with_warning
|
69
|
+
else
|
70
|
+
Hakuban::FFI::hakuban_future_drop(future_pointer_for_blocking_await)
|
71
|
+
end
|
72
|
+
return [result, error]
|
159
73
|
end
|
74
|
+
|
160
75
|
end
|
161
76
|
|
162
77
|
|
163
78
|
class FFIArray < FFI::Struct
|
164
79
|
layout :length, :size_t, :pointer, :pointer
|
165
80
|
end
|
166
|
-
|
167
81
|
|
168
|
-
# Every function which can cause a wake() has to be "blocking: true".
|
169
|
-
# Otherwise they are very likely to deadlock on GVL and other locks acquired by RemoteExchange on incomming message.
|
170
|
-
# FIXME: way too many functions are marked as blocking here
|
171
82
|
|
172
|
-
callback
|
83
|
+
# Every function which can cause a callback has to be "blocking: true".
|
84
|
+
# Otherwise they are very likely to deadlock on GVL and other locks acquired by Connection(s) on incomming message
|
85
|
+
# Fortunately, we don't use callbacks any more. And the only function with unbounded execution time is the future-await. So, only setting that one as blocking.
|
86
|
+
|
87
|
+
callback :waker, [ :pointer ], :void
|
173
88
|
|
174
|
-
attach_function :hakuban_logger_initialize, [ :string ],
|
89
|
+
attach_function :hakuban_logger_initialize, [ :string ], FFIResult.by_value
|
175
90
|
|
176
|
-
attach_function :
|
177
|
-
attach_function :
|
178
|
-
attach_function :
|
91
|
+
attach_function :hakuban_exchange_new, [ ], FFIResult.by_value
|
92
|
+
attach_function :hakuban_exchange_drop, [ :pointer ], :void
|
93
|
+
attach_function :hakuban_exchange_clone, [ :pointer ], :pointer
|
179
94
|
|
180
95
|
attach_function :hakuban_tokio_init_multi_thread, [ :size_t ], :pointer
|
181
|
-
attach_function :hakuban_tokio_websocket_connector_new, [ :pointer, :pointer, :string ],
|
182
|
-
attach_function :hakuban_tokio_websocket_connector_drop, [ :pointer ], :void
|
183
|
-
|
184
|
-
attach_function :hakuban_object_observe_contract_new, [ :pointer, :pointer ], :pointer
|
185
|
-
attach_function :hakuban_object_observe_contract_drop, [ :pointer ], :void
|
186
|
-
attach_function :
|
187
|
-
|
188
|
-
attach_function :
|
189
|
-
|
190
|
-
attach_function :
|
191
|
-
|
192
|
-
attach_function :
|
193
|
-
attach_function :
|
194
|
-
attach_function :
|
195
|
-
|
196
|
-
attach_function :
|
197
|
-
attach_function :
|
198
|
-
attach_function :
|
199
|
-
|
200
|
-
attach_function :
|
201
|
-
|
202
|
-
attach_function :hakuban_tag_expose_contract_new, [ :pointer, :pointer ], :pointer, blocking: true
|
203
|
-
attach_function :hakuban_tag_expose_contract_drop, [ :pointer ], :void, blocking: true
|
204
|
-
attach_function :hakuban_tag_expose_contract_terminate, [ :pointer ], :void, blocking: true
|
205
|
-
attach_function :hakuban_tag_expose_contract_next, [ :pointer ], FFIFutureReturningPointer.by_value, blocking: true
|
206
|
-
attach_function :hakuban_tag_expose_contract_ready, [ :pointer ], FFIArray.by_value, blocking: true
|
207
|
-
|
208
|
-
attach_function :hakuban_object_state_stream_drop, [ :pointer ], :void, blocking: true
|
209
|
-
attach_function :hakuban_object_state_stream_next, [ :pointer ], FFIFutureReturningPointer.by_value, blocking: true
|
210
|
-
attach_function :hakuban_object_state_stream_current, [ :pointer ], FFIResultWithPointer.by_value
|
96
|
+
attach_function :hakuban_tokio_websocket_connector_new, [ :pointer, :pointer, :string ], FFIResult.by_value
|
97
|
+
attach_function :hakuban_tokio_websocket_connector_drop, [ :pointer ], :void
|
98
|
+
|
99
|
+
attach_function :hakuban_object_observe_contract_new, [ :pointer, :pointer ], :pointer
|
100
|
+
attach_function :hakuban_object_observe_contract_drop, [ :pointer ], :void
|
101
|
+
attach_function :hakuban_object_observe_contract_next, [ :pointer ], :pointer
|
102
|
+
|
103
|
+
attach_function :hakuban_object_expose_contract_new, [ :pointer, :pointer, :uint32 ], :pointer
|
104
|
+
attach_function :hakuban_object_expose_contract_drop, [ :pointer ], :void
|
105
|
+
attach_function :hakuban_object_expose_contract_next, [ :pointer ], :pointer
|
106
|
+
|
107
|
+
attach_function :hakuban_tag_observe_contract_new, [ :pointer, :pointer ], :pointer
|
108
|
+
attach_function :hakuban_tag_observe_contract_drop, [ :pointer ], :void
|
109
|
+
attach_function :hakuban_tag_observe_contract_next, [ :pointer ], :pointer
|
110
|
+
|
111
|
+
attach_function :hakuban_tag_expose_contract_new, [ :pointer, :pointer, :uint32 ], :pointer
|
112
|
+
attach_function :hakuban_tag_expose_contract_drop, [ :pointer ], :void
|
113
|
+
attach_function :hakuban_tag_expose_contract_next, [ :pointer ], :pointer
|
114
|
+
|
115
|
+
attach_function :hakuban_object_state_stream_drop, [ :pointer ], :void
|
116
|
+
attach_function :hakuban_object_state_stream_next, [ :pointer ], :pointer
|
211
117
|
attach_function :hakuban_object_state_stream_descriptor, [ :pointer ], :pointer
|
212
118
|
|
213
|
-
attach_function :hakuban_object_state_sink_drop, [ :pointer ], :void
|
214
|
-
attach_function :hakuban_object_state_sink_next, [ :pointer ],
|
215
|
-
attach_function :hakuban_object_state_sink_send, [ :pointer, :pointer ],
|
216
|
-
attach_function :hakuban_object_state_sink_current, [ :pointer ], FFIResultWithPointer.by_value, blocking: true
|
119
|
+
attach_function :hakuban_object_state_sink_drop, [ :pointer ], :void
|
120
|
+
attach_function :hakuban_object_state_sink_next, [ :pointer ], :pointer
|
121
|
+
attach_function :hakuban_object_state_sink_send, [ :pointer, :pointer ], :pointer
|
217
122
|
attach_function :hakuban_object_state_sink_descriptor, [ :pointer ], :pointer
|
218
|
-
attach_function :hakuban_object_state_sink_desynchronize, [ :pointer ], :void, blocking: true
|
219
123
|
|
220
124
|
attach_function :hakuban_object_state_sink_params_drop, [ :pointer ], :void
|
221
125
|
attach_function :hakuban_object_state_sink_params_clone, [ :pointer ], :pointer
|
222
126
|
|
223
|
-
attach_function :hakuban_object_state_new, [ :size_t, :pointer, :size_t, :pointer, :size_t, :pointer, :uint64 ],
|
127
|
+
attach_function :hakuban_object_state_new, [ :size_t, :pointer, :size_t, :pointer, :size_t, :pointer, :uint64 ], FFIResult.by_value
|
224
128
|
attach_function :hakuban_object_state_drop, [ :pointer ], :void
|
225
129
|
attach_function :hakuban_object_state_clone, [ :pointer ], :pointer
|
226
130
|
attach_function :hakuban_object_state_data, [ :pointer ], FFIArray.by_value
|
@@ -228,23 +132,26 @@ module Hakuban::FFI
|
|
228
132
|
attach_function :hakuban_object_state_version, [ :pointer ], FFIArray.by_value
|
229
133
|
attach_function :hakuban_object_state_synchronized_ago, [ :pointer ], :uint64
|
230
134
|
|
231
|
-
attach_function :hakuban_tag_descriptor_new, [ :string ],
|
135
|
+
attach_function :hakuban_tag_descriptor_new, [ :string ], FFIResult.by_value
|
232
136
|
attach_function :hakuban_tag_descriptor_drop, [ :pointer ], :void
|
233
137
|
attach_function :hakuban_tag_descriptor_clone, [ :pointer ], :pointer
|
234
138
|
attach_function :hakuban_tag_descriptor_json, [ :pointer ], :string
|
235
139
|
|
236
|
-
attach_function :hakuban_object_descriptor_new, [ :string, :size_t, :pointer ],
|
140
|
+
attach_function :hakuban_object_descriptor_new, [ :string, :size_t, :pointer ], FFIResult.by_value
|
237
141
|
attach_function :hakuban_object_descriptor_drop, [ :pointer ], :void
|
238
142
|
attach_function :hakuban_object_descriptor_clone, [ :pointer ], :pointer
|
239
143
|
attach_function :hakuban_object_descriptor_json, [ :pointer ], :string
|
240
144
|
attach_function :hakuban_object_descriptor_tags, [ :pointer ], FFIArray.by_value
|
241
145
|
|
242
|
-
attach_function :
|
243
|
-
attach_function :
|
244
|
-
attach_function :
|
245
|
-
attach_function :
|
146
|
+
attach_function :hakuban_future_clone, [ :pointer ], :pointer
|
147
|
+
attach_function :hakuban_future_drop, [ :pointer ], :void
|
148
|
+
#attach_function :hakuban_future_poll, [ :pointer, :waker, :pointer ], FFIResult.by_value #this is pita to get working right with interrupts, and without leaking memory in weird cases
|
149
|
+
attach_function :hakuban_future_await, [ :pointer ], FFIResult.by_value, blocking: true
|
246
150
|
|
247
151
|
attach_function :hakuban_array_drop, [ FFIArray.by_value ], :void
|
248
152
|
|
153
|
+
FFIResultStatus.freeze
|
154
|
+
FFIResult.freeze
|
155
|
+
FFIFuture.freeze
|
156
|
+
freeze
|
249
157
|
end
|
250
|
-
|
data/lib/hakuban/logger.rb
CHANGED
@@ -5,10 +5,10 @@ module Hakuban
|
|
5
5
|
def self.logger_initialize(default_level, skip_if_already_initialized: false)
|
6
6
|
Hakuban::hakuban_initialize
|
7
7
|
if @@logger_initialized and !skip_if_already_initialized
|
8
|
-
raise "Logger already initialized. This can't be done more than once. Make sure logger_initialize is called before any
|
8
|
+
raise "Logger already initialized. This can't be done more than once. Make sure logger_initialize is called before any Exchange gets constructed."
|
9
9
|
end
|
10
10
|
if not @@logger_initialized
|
11
|
-
raise "Invalid default log level string" if
|
11
|
+
raise "Invalid default log level string" if FFI::hakuban_logger_initialize(default_level).status != :Ok
|
12
12
|
@@logger_initialized = true
|
13
13
|
end
|
14
14
|
end
|