datawire_mdk 2.0.5
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 +7 -0
- data/lib/datawire-quark-core.rb +1213 -0
- data/lib/datawire_mdk_md.rb +54752 -0
- data/lib/mdk.rb +962 -0
- data/lib/mdk_discovery.rb +1518 -0
- data/lib/mdk_discovery/protocol.rb +818 -0
- data/lib/mdk_discovery/synapse.rb +267 -0
- data/lib/mdk_introspection.rb +281 -0
- data/lib/mdk_introspection/aws.rb +101 -0
- data/lib/mdk_introspection/kubernetes.rb +125 -0
- data/lib/mdk_protocol.rb +1255 -0
- data/lib/mdk_runtime.rb +2135 -0
- data/lib/mdk_runtime/actors.rb +457 -0
- data/lib/mdk_runtime/files.rb +575 -0
- data/lib/mdk_runtime/promise.rb +814 -0
- data/lib/mdk_tracing.rb +369 -0
- data/lib/mdk_tracing/api.rb +188 -0
- data/lib/mdk_tracing/protocol.rb +850 -0
- data/lib/mdk_util.rb +141 -0
- data/lib/quark.rb +3684 -0
- data/lib/quark/behaviors.rb +494 -0
- data/lib/quark/concurrent.rb +1250 -0
- data/lib/quark/error.rb +84 -0
- data/lib/quark/logging.rb +278 -0
- data/lib/quark/mock.rb +1223 -0
- data/lib/quark/os.rb +286 -0
- data/lib/quark/reflect.rb +489 -0
- data/lib/quark/spi.rb +130 -0
- data/lib/quark/spi_api.rb +489 -0
- data/lib/quark/spi_api_tracing.rb +1426 -0
- data/lib/quark/test.rb +766 -0
- metadata +142 -0
@@ -0,0 +1,1250 @@
|
|
1
|
+
# Quark 1.0.406 run at 2016-08-31 13:21:53.028839
|
2
|
+
module Quark
|
3
|
+
def self.quark; Quark; end
|
4
|
+
module Quark
|
5
|
+
def self.concurrent; Concurrent; end
|
6
|
+
module Concurrent
|
7
|
+
require "datawire-quark-core"
|
8
|
+
require_relative 'reflect' # 1 () ()
|
9
|
+
require_relative '../datawire_mdk_md' # 0 () ('quark',)
|
10
|
+
require_relative 'error' # 1 () ()
|
11
|
+
require_relative '../quark' # 0 () ('quark',)
|
12
|
+
require_relative 'spi' # 1 () ()
|
13
|
+
|
14
|
+
|
15
|
+
def self.Event; Event; end
|
16
|
+
##
|
17
|
+
# The contract between event implementations and Collector
|
18
|
+
|
19
|
+
class Event < ::DatawireQuarkCore::QuarkObject
|
20
|
+
extend ::DatawireQuarkCore::Static
|
21
|
+
|
22
|
+
static quark_concurrent_Event_ref: -> { nil }
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
def initialize()
|
27
|
+
self.__init_fields__
|
28
|
+
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
def getContext()
|
36
|
+
raise NotImplementedError, '`Event.getContext` is an abstract method'
|
37
|
+
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
|
41
|
+
def fireEvent()
|
42
|
+
raise NotImplementedError, '`Event.fireEvent` is an abstract method'
|
43
|
+
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
|
47
|
+
def __init_fields__()
|
48
|
+
|
49
|
+
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
end
|
55
|
+
Event.unlazy_statics
|
56
|
+
|
57
|
+
def self.FutureListener; FutureListener; end
|
58
|
+
##
|
59
|
+
# event handler for a future completion
|
60
|
+
|
61
|
+
class FutureListener < ::DatawireQuarkCore::QuarkObject
|
62
|
+
extend ::DatawireQuarkCore::Static
|
63
|
+
|
64
|
+
static quark_concurrent_FutureListener_ref: -> { nil }
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
def initialize()
|
69
|
+
self.__init_fields__
|
70
|
+
|
71
|
+
nil
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
def onFuture(future)
|
78
|
+
|
79
|
+
nil
|
80
|
+
|
81
|
+
nil
|
82
|
+
end
|
83
|
+
|
84
|
+
def __init_fields__()
|
85
|
+
|
86
|
+
|
87
|
+
nil
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
end
|
92
|
+
FutureListener.unlazy_statics
|
93
|
+
|
94
|
+
def self.FutureCompletion; FutureCompletion; end
|
95
|
+
##
|
96
|
+
# internal class that binds a listener to a future
|
97
|
+
|
98
|
+
class FutureCompletion < ::DatawireQuarkCore::QuarkObject
|
99
|
+
attr_accessor :future, :listener
|
100
|
+
extend ::DatawireQuarkCore::Static
|
101
|
+
|
102
|
+
static quark_concurrent_FutureCompletion_ref: -> { nil }
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
def initialize(future, listener)
|
107
|
+
|
108
|
+
self.__init_fields__
|
109
|
+
(self).future = future
|
110
|
+
(self).listener = listener
|
111
|
+
|
112
|
+
nil
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
def getContext()
|
119
|
+
|
120
|
+
return (self).future
|
121
|
+
|
122
|
+
nil
|
123
|
+
end
|
124
|
+
|
125
|
+
def fireEvent()
|
126
|
+
|
127
|
+
(self).listener.onFuture((self).future)
|
128
|
+
|
129
|
+
nil
|
130
|
+
end
|
131
|
+
|
132
|
+
def _getClass()
|
133
|
+
|
134
|
+
return "quark.concurrent.FutureCompletion"
|
135
|
+
|
136
|
+
nil
|
137
|
+
end
|
138
|
+
|
139
|
+
def _getField(name)
|
140
|
+
|
141
|
+
if ((name) == ("future"))
|
142
|
+
return (self).future
|
143
|
+
end
|
144
|
+
if ((name) == ("listener"))
|
145
|
+
return (self).listener
|
146
|
+
end
|
147
|
+
return nil
|
148
|
+
|
149
|
+
nil
|
150
|
+
end
|
151
|
+
|
152
|
+
def _setField(name, value)
|
153
|
+
|
154
|
+
if ((name) == ("future"))
|
155
|
+
(self).future = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.Future }
|
156
|
+
end
|
157
|
+
if ((name) == ("listener"))
|
158
|
+
(self).listener = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.FutureListener }
|
159
|
+
end
|
160
|
+
|
161
|
+
nil
|
162
|
+
end
|
163
|
+
|
164
|
+
def __init_fields__()
|
165
|
+
|
166
|
+
self.future = nil
|
167
|
+
self.listener = nil
|
168
|
+
|
169
|
+
nil
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
end
|
174
|
+
FutureCompletion.unlazy_statics
|
175
|
+
|
176
|
+
def self.EventContext; EventContext; end
|
177
|
+
##
|
178
|
+
# Captures the current context, base class for all event source implementations
|
179
|
+
|
180
|
+
class EventContext < ::DatawireQuarkCore::QuarkObject
|
181
|
+
attr_accessor :_context
|
182
|
+
extend ::DatawireQuarkCore::Static
|
183
|
+
|
184
|
+
static quark_concurrent_EventContext_ref: -> { nil }
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
def initialize()
|
189
|
+
|
190
|
+
self.__init_fields__
|
191
|
+
(self)._context = ::Quark.quark.concurrent.Context.current()
|
192
|
+
|
193
|
+
nil
|
194
|
+
end
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
def getContext()
|
200
|
+
|
201
|
+
return (self)._context
|
202
|
+
|
203
|
+
nil
|
204
|
+
end
|
205
|
+
|
206
|
+
def _getClass()
|
207
|
+
|
208
|
+
return "quark.concurrent.EventContext"
|
209
|
+
|
210
|
+
nil
|
211
|
+
end
|
212
|
+
|
213
|
+
def _getField(name)
|
214
|
+
|
215
|
+
if ((name) == ("_context"))
|
216
|
+
return (self)._context
|
217
|
+
end
|
218
|
+
return nil
|
219
|
+
|
220
|
+
nil
|
221
|
+
end
|
222
|
+
|
223
|
+
def _setField(name, value)
|
224
|
+
|
225
|
+
if ((name) == ("_context"))
|
226
|
+
(self)._context = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.Context }
|
227
|
+
end
|
228
|
+
|
229
|
+
nil
|
230
|
+
end
|
231
|
+
|
232
|
+
def __init_fields__()
|
233
|
+
|
234
|
+
self._context = nil
|
235
|
+
|
236
|
+
nil
|
237
|
+
end
|
238
|
+
|
239
|
+
|
240
|
+
end
|
241
|
+
EventContext.unlazy_statics
|
242
|
+
|
243
|
+
def self.Future; Future; end
|
244
|
+
##
|
245
|
+
# The base class for value objects
|
246
|
+
|
247
|
+
class Future < ::Quark.quark.concurrent.EventContext
|
248
|
+
attr_accessor :_finished, :_error, :_callbacks, :_lock
|
249
|
+
extend ::DatawireQuarkCore::Static
|
250
|
+
|
251
|
+
static quark_List_quark_concurrent_FutureCompletion__ref: -> { nil }
|
252
|
+
static quark_concurrent_Future_ref: -> { nil }
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
def initialize()
|
257
|
+
|
258
|
+
super()
|
259
|
+
(self)._finished = false
|
260
|
+
(self)._callbacks = ::DatawireQuarkCore.cast(nil) { ::DatawireQuarkCore::List }
|
261
|
+
(self)._lock = ::DatawireQuarkCore::Lock.new()
|
262
|
+
|
263
|
+
nil
|
264
|
+
end
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
def onFinished(callback)
|
270
|
+
|
271
|
+
(self)._lock.acquire()
|
272
|
+
if ((self)._finished)
|
273
|
+
((self)._context).collector.put(::Quark.quark.concurrent.FutureCompletion.new(self, callback))
|
274
|
+
else
|
275
|
+
if (((self)._callbacks) == (nil))
|
276
|
+
(self)._callbacks = ::DatawireQuarkCore::List.new([])
|
277
|
+
end
|
278
|
+
((self)._callbacks) << (::Quark.quark.concurrent.FutureCompletion.new(self, callback))
|
279
|
+
end
|
280
|
+
(self)._lock.release()
|
281
|
+
|
282
|
+
nil
|
283
|
+
end
|
284
|
+
|
285
|
+
def finish(error)
|
286
|
+
|
287
|
+
callbacks = ::DatawireQuarkCore.cast(nil) { ::DatawireQuarkCore::List }
|
288
|
+
(self)._lock.acquire()
|
289
|
+
if (!((self)._finished))
|
290
|
+
(self)._finished = true
|
291
|
+
(self)._error = error
|
292
|
+
callbacks = (self)._callbacks
|
293
|
+
(self)._callbacks = ::DatawireQuarkCore.cast(nil) { ::DatawireQuarkCore::List }
|
294
|
+
end
|
295
|
+
(self)._lock.release()
|
296
|
+
if ((callbacks) != (nil))
|
297
|
+
i = 0
|
298
|
+
while ((i) < ((callbacks).size)) do
|
299
|
+
((self)._context).collector.put((callbacks)[i])
|
300
|
+
i = (i) + (1)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
nil
|
305
|
+
end
|
306
|
+
|
307
|
+
def isFinished()
|
308
|
+
|
309
|
+
(self)._lock.acquire()
|
310
|
+
finished = (self)._finished
|
311
|
+
(self)._lock.release()
|
312
|
+
return finished
|
313
|
+
|
314
|
+
nil
|
315
|
+
end
|
316
|
+
|
317
|
+
def getError()
|
318
|
+
|
319
|
+
(self)._lock.acquire()
|
320
|
+
error = (self)._error
|
321
|
+
(self)._lock.release()
|
322
|
+
return error
|
323
|
+
|
324
|
+
nil
|
325
|
+
end
|
326
|
+
|
327
|
+
def await(timeout)
|
328
|
+
|
329
|
+
::Quark.quark.concurrent.FutureWait.new().wait(self, timeout)
|
330
|
+
|
331
|
+
nil
|
332
|
+
end
|
333
|
+
|
334
|
+
def _getClass()
|
335
|
+
|
336
|
+
return "quark.concurrent.Future"
|
337
|
+
|
338
|
+
nil
|
339
|
+
end
|
340
|
+
|
341
|
+
def _getField(name)
|
342
|
+
|
343
|
+
if ((name) == ("_context"))
|
344
|
+
return (self)._context
|
345
|
+
end
|
346
|
+
if ((name) == ("_finished"))
|
347
|
+
return (self)._finished
|
348
|
+
end
|
349
|
+
if ((name) == ("_error"))
|
350
|
+
return (self)._error
|
351
|
+
end
|
352
|
+
if ((name) == ("_callbacks"))
|
353
|
+
return (self)._callbacks
|
354
|
+
end
|
355
|
+
if ((name) == ("_lock"))
|
356
|
+
return (self)._lock
|
357
|
+
end
|
358
|
+
return nil
|
359
|
+
|
360
|
+
nil
|
361
|
+
end
|
362
|
+
|
363
|
+
def _setField(name, value)
|
364
|
+
|
365
|
+
if ((name) == ("_context"))
|
366
|
+
(self)._context = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.Context }
|
367
|
+
end
|
368
|
+
if ((name) == ("_finished"))
|
369
|
+
(self)._finished = ::DatawireQuarkCore.cast(value) { ::Object }
|
370
|
+
end
|
371
|
+
if ((name) == ("_error"))
|
372
|
+
(self)._error = ::DatawireQuarkCore.cast(value) { ::Quark.quark.error.Error }
|
373
|
+
end
|
374
|
+
if ((name) == ("_callbacks"))
|
375
|
+
(self)._callbacks = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::List }
|
376
|
+
end
|
377
|
+
if ((name) == ("_lock"))
|
378
|
+
(self)._lock = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::Lock }
|
379
|
+
end
|
380
|
+
|
381
|
+
nil
|
382
|
+
end
|
383
|
+
|
384
|
+
def __init_fields__()
|
385
|
+
|
386
|
+
super
|
387
|
+
self._finished = nil
|
388
|
+
self._error = nil
|
389
|
+
self._callbacks = nil
|
390
|
+
self._lock = nil
|
391
|
+
|
392
|
+
nil
|
393
|
+
end
|
394
|
+
|
395
|
+
|
396
|
+
end
|
397
|
+
Future.unlazy_statics
|
398
|
+
|
399
|
+
def self.FutureWait; FutureWait; end
|
400
|
+
##
|
401
|
+
# Synchronization point for a Future.)
|
402
|
+
|
403
|
+
class FutureWait < ::DatawireQuarkCore::QuarkObject
|
404
|
+
attr_accessor :_lock, :_future
|
405
|
+
extend ::DatawireQuarkCore::Static
|
406
|
+
|
407
|
+
static quark_concurrent_FutureWait_ref: -> { nil }
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
def initialize()
|
412
|
+
|
413
|
+
self.__init_fields__
|
414
|
+
(self)._lock = ::DatawireQuarkCore::Condition.new()
|
415
|
+
(self)._future = ::DatawireQuarkCore.cast(nil) { ::Quark.quark.concurrent.Future }
|
416
|
+
|
417
|
+
nil
|
418
|
+
end
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
def wait(future, timeout)
|
424
|
+
|
425
|
+
if (future.isFinished())
|
426
|
+
return
|
427
|
+
end
|
428
|
+
(self)._future = future
|
429
|
+
(self)._future.onFinished(self)
|
430
|
+
rounded = ((1000.0) * (timeout)).round()
|
431
|
+
deadline = (::Quark.quark.now()) + (rounded)
|
432
|
+
while (!((self)._future.isFinished())) do
|
433
|
+
remaining = (deadline) - (::Quark.quark.now())
|
434
|
+
if ((rounded) != (0))
|
435
|
+
if ((remaining) <= ((0)))
|
436
|
+
break
|
437
|
+
end
|
438
|
+
else
|
439
|
+
remaining = (3141)
|
440
|
+
end
|
441
|
+
(self)._lock.acquire()
|
442
|
+
(self)._lock.waitWakeup(remaining)
|
443
|
+
(self)._lock.release()
|
444
|
+
end
|
445
|
+
(self)._future = ::DatawireQuarkCore.cast(nil) { ::Quark.quark.concurrent.Future }
|
446
|
+
|
447
|
+
nil
|
448
|
+
end
|
449
|
+
|
450
|
+
def onFuture(future)
|
451
|
+
|
452
|
+
(self)._lock.acquire()
|
453
|
+
(self)._lock.wakeup()
|
454
|
+
(self)._lock.release()
|
455
|
+
|
456
|
+
nil
|
457
|
+
end
|
458
|
+
|
459
|
+
def self.waitFor(future, timeout)
|
460
|
+
|
461
|
+
if (false)
|
462
|
+
w = ::Quark.quark.concurrent.FutureWait.new()
|
463
|
+
w.wait(future, timeout)
|
464
|
+
if (!(future.isFinished()))
|
465
|
+
nil
|
466
|
+
end
|
467
|
+
end
|
468
|
+
return future
|
469
|
+
|
470
|
+
nil
|
471
|
+
end
|
472
|
+
|
473
|
+
def _getClass()
|
474
|
+
|
475
|
+
return "quark.concurrent.FutureWait"
|
476
|
+
|
477
|
+
nil
|
478
|
+
end
|
479
|
+
|
480
|
+
def _getField(name)
|
481
|
+
|
482
|
+
if ((name) == ("_lock"))
|
483
|
+
return (self)._lock
|
484
|
+
end
|
485
|
+
if ((name) == ("_future"))
|
486
|
+
return (self)._future
|
487
|
+
end
|
488
|
+
return nil
|
489
|
+
|
490
|
+
nil
|
491
|
+
end
|
492
|
+
|
493
|
+
def _setField(name, value)
|
494
|
+
|
495
|
+
if ((name) == ("_lock"))
|
496
|
+
(self)._lock = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::Condition }
|
497
|
+
end
|
498
|
+
if ((name) == ("_future"))
|
499
|
+
(self)._future = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.Future }
|
500
|
+
end
|
501
|
+
|
502
|
+
nil
|
503
|
+
end
|
504
|
+
|
505
|
+
def __init_fields__()
|
506
|
+
|
507
|
+
self._lock = nil
|
508
|
+
self._future = nil
|
509
|
+
|
510
|
+
nil
|
511
|
+
end
|
512
|
+
|
513
|
+
|
514
|
+
end
|
515
|
+
FutureWait.unlazy_statics
|
516
|
+
|
517
|
+
def self.Queue; Queue; end
|
518
|
+
##
|
519
|
+
# A simple FIFO
|
520
|
+
|
521
|
+
class Queue < ::DatawireQuarkCore::QuarkObject
|
522
|
+
attr_accessor :items, :head, :tail
|
523
|
+
|
524
|
+
|
525
|
+
|
526
|
+
def initialize()
|
527
|
+
|
528
|
+
self.__init_fields__
|
529
|
+
(self).items = ::DatawireQuarkCore::List.new()
|
530
|
+
(self).head = 0
|
531
|
+
(self).tail = 0
|
532
|
+
|
533
|
+
nil
|
534
|
+
end
|
535
|
+
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
def put(item)
|
540
|
+
|
541
|
+
if (((self).tail) < (((self).items).size))
|
542
|
+
((self).items)[(self).tail] = (item)
|
543
|
+
else
|
544
|
+
((self).items) << (item)
|
545
|
+
end
|
546
|
+
(self).tail = ((self).tail) + (1)
|
547
|
+
|
548
|
+
nil
|
549
|
+
end
|
550
|
+
|
551
|
+
def get()
|
552
|
+
|
553
|
+
item = ::DatawireQuarkCore.cast(nil) { ::Quark.T }
|
554
|
+
if (((self).head) < ((self).tail))
|
555
|
+
item = ((self).items)[(self).head]
|
556
|
+
(self).head = ((self).head) + (1)
|
557
|
+
else
|
558
|
+
if (((self).head) > (0))
|
559
|
+
(self).head = 0
|
560
|
+
(self).tail = 0
|
561
|
+
end
|
562
|
+
end
|
563
|
+
return item
|
564
|
+
|
565
|
+
nil
|
566
|
+
end
|
567
|
+
|
568
|
+
def size()
|
569
|
+
|
570
|
+
return ((self).tail) - ((self).head)
|
571
|
+
|
572
|
+
nil
|
573
|
+
end
|
574
|
+
|
575
|
+
def _getClass()
|
576
|
+
|
577
|
+
return "quark.concurrent.Queue<quark.Object>"
|
578
|
+
|
579
|
+
nil
|
580
|
+
end
|
581
|
+
|
582
|
+
def _getField(name)
|
583
|
+
|
584
|
+
if ((name) == ("items"))
|
585
|
+
return (self).items
|
586
|
+
end
|
587
|
+
if ((name) == ("head"))
|
588
|
+
return (self).head
|
589
|
+
end
|
590
|
+
if ((name) == ("tail"))
|
591
|
+
return (self).tail
|
592
|
+
end
|
593
|
+
return nil
|
594
|
+
|
595
|
+
nil
|
596
|
+
end
|
597
|
+
|
598
|
+
def _setField(name, value)
|
599
|
+
|
600
|
+
if ((name) == ("items"))
|
601
|
+
(self).items = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::List }
|
602
|
+
end
|
603
|
+
if ((name) == ("head"))
|
604
|
+
(self).head = ::DatawireQuarkCore.cast(value) { ::Integer }
|
605
|
+
end
|
606
|
+
if ((name) == ("tail"))
|
607
|
+
(self).tail = ::DatawireQuarkCore.cast(value) { ::Integer }
|
608
|
+
end
|
609
|
+
|
610
|
+
nil
|
611
|
+
end
|
612
|
+
|
613
|
+
def __init_fields__()
|
614
|
+
|
615
|
+
self.items = nil
|
616
|
+
self.head = nil
|
617
|
+
self.tail = nil
|
618
|
+
|
619
|
+
nil
|
620
|
+
end
|
621
|
+
|
622
|
+
|
623
|
+
end
|
624
|
+
|
625
|
+
def self.CollectorExecutor; CollectorExecutor; end
|
626
|
+
##
|
627
|
+
# Fire events one by one with no locks held
|
628
|
+
|
629
|
+
class CollectorExecutor < ::DatawireQuarkCore::QuarkObject
|
630
|
+
attr_accessor :events, :collector
|
631
|
+
extend ::DatawireQuarkCore::Static
|
632
|
+
|
633
|
+
static quark_concurrent_Queue_quark_concurrent_Event__ref: -> { nil }
|
634
|
+
static quark_concurrent_CollectorExecutor_ref: -> { nil }
|
635
|
+
|
636
|
+
|
637
|
+
|
638
|
+
def initialize(collector)
|
639
|
+
|
640
|
+
self.__init_fields__
|
641
|
+
(self).events = ::Quark.quark.concurrent.Queue.new()
|
642
|
+
(self).collector = collector
|
643
|
+
|
644
|
+
nil
|
645
|
+
end
|
646
|
+
|
647
|
+
|
648
|
+
|
649
|
+
|
650
|
+
def _start()
|
651
|
+
|
652
|
+
(self).events = (self).collector._swap((self).events)
|
653
|
+
if (((self).events.size()) > (0))
|
654
|
+
::Quark.quark.concurrent.Context.runtime().schedule(self, 0.0)
|
655
|
+
end
|
656
|
+
|
657
|
+
nil
|
658
|
+
end
|
659
|
+
|
660
|
+
def onExecute(runtime)
|
661
|
+
|
662
|
+
next_ = (self).events.get()
|
663
|
+
old = ::Quark.quark.concurrent.Context.current()
|
664
|
+
while ((next_) != (nil)) do
|
665
|
+
::Quark.quark.concurrent.Context.swap(next_.getContext().getContext())
|
666
|
+
next_.fireEvent()
|
667
|
+
next_ = (self).events.get()
|
668
|
+
end
|
669
|
+
::Quark.quark.concurrent.Context.swap(old)
|
670
|
+
(self).collector._poll()
|
671
|
+
|
672
|
+
nil
|
673
|
+
end
|
674
|
+
|
675
|
+
def _getClass()
|
676
|
+
|
677
|
+
return "quark.concurrent.CollectorExecutor"
|
678
|
+
|
679
|
+
nil
|
680
|
+
end
|
681
|
+
|
682
|
+
def _getField(name)
|
683
|
+
|
684
|
+
if ((name) == ("events"))
|
685
|
+
return (self).events
|
686
|
+
end
|
687
|
+
if ((name) == ("collector"))
|
688
|
+
return (self).collector
|
689
|
+
end
|
690
|
+
return nil
|
691
|
+
|
692
|
+
nil
|
693
|
+
end
|
694
|
+
|
695
|
+
def _setField(name, value)
|
696
|
+
|
697
|
+
if ((name) == ("events"))
|
698
|
+
(self).events = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.Queue }
|
699
|
+
end
|
700
|
+
if ((name) == ("collector"))
|
701
|
+
(self).collector = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.Collector }
|
702
|
+
end
|
703
|
+
|
704
|
+
nil
|
705
|
+
end
|
706
|
+
|
707
|
+
def __init_fields__()
|
708
|
+
|
709
|
+
self.events = nil
|
710
|
+
self.collector = nil
|
711
|
+
|
712
|
+
nil
|
713
|
+
end
|
714
|
+
|
715
|
+
|
716
|
+
end
|
717
|
+
CollectorExecutor.unlazy_statics
|
718
|
+
|
719
|
+
def self.Collector; Collector; end
|
720
|
+
##
|
721
|
+
# An active queue of events. Each event will fire sequentially, one by one. Multiple instances of Collector are not serialized with eachother and may run in parallel.
|
722
|
+
|
723
|
+
class Collector < ::DatawireQuarkCore::QuarkObject
|
724
|
+
attr_accessor :lock, :pending, :executor, :idle
|
725
|
+
extend ::DatawireQuarkCore::Static
|
726
|
+
|
727
|
+
static quark_concurrent_Collector_ref: -> { nil }
|
728
|
+
|
729
|
+
|
730
|
+
|
731
|
+
def initialize()
|
732
|
+
|
733
|
+
self.__init_fields__
|
734
|
+
(self).lock = ::DatawireQuarkCore::Lock.new()
|
735
|
+
(self).pending = ::Quark.quark.concurrent.Queue.new()
|
736
|
+
(self).executor = ::Quark.quark.concurrent.CollectorExecutor.new(self)
|
737
|
+
(self).idle = true
|
738
|
+
|
739
|
+
nil
|
740
|
+
end
|
741
|
+
|
742
|
+
|
743
|
+
|
744
|
+
|
745
|
+
def put(event)
|
746
|
+
|
747
|
+
(self).lock.acquire()
|
748
|
+
(self).pending.put(event)
|
749
|
+
if ((self).idle)
|
750
|
+
(self).executor._start()
|
751
|
+
end
|
752
|
+
(self).lock.release()
|
753
|
+
|
754
|
+
nil
|
755
|
+
end
|
756
|
+
|
757
|
+
def _swap(drained)
|
758
|
+
|
759
|
+
pending = (self).pending
|
760
|
+
(self).idle = (pending.size()) == (0)
|
761
|
+
(self).pending = drained
|
762
|
+
return pending
|
763
|
+
|
764
|
+
nil
|
765
|
+
end
|
766
|
+
|
767
|
+
def _poll()
|
768
|
+
|
769
|
+
(self).lock.acquire()
|
770
|
+
(self).executor._start()
|
771
|
+
(self).lock.release()
|
772
|
+
|
773
|
+
nil
|
774
|
+
end
|
775
|
+
|
776
|
+
def _getClass()
|
777
|
+
|
778
|
+
return "quark.concurrent.Collector"
|
779
|
+
|
780
|
+
nil
|
781
|
+
end
|
782
|
+
|
783
|
+
def _getField(name)
|
784
|
+
|
785
|
+
if ((name) == ("lock"))
|
786
|
+
return (self).lock
|
787
|
+
end
|
788
|
+
if ((name) == ("pending"))
|
789
|
+
return (self).pending
|
790
|
+
end
|
791
|
+
if ((name) == ("executor"))
|
792
|
+
return (self).executor
|
793
|
+
end
|
794
|
+
if ((name) == ("idle"))
|
795
|
+
return (self).idle
|
796
|
+
end
|
797
|
+
return nil
|
798
|
+
|
799
|
+
nil
|
800
|
+
end
|
801
|
+
|
802
|
+
def _setField(name, value)
|
803
|
+
|
804
|
+
if ((name) == ("lock"))
|
805
|
+
(self).lock = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::Lock }
|
806
|
+
end
|
807
|
+
if ((name) == ("pending"))
|
808
|
+
(self).pending = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.Queue }
|
809
|
+
end
|
810
|
+
if ((name) == ("executor"))
|
811
|
+
(self).executor = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.CollectorExecutor }
|
812
|
+
end
|
813
|
+
if ((name) == ("idle"))
|
814
|
+
(self).idle = ::DatawireQuarkCore.cast(value) { ::Object }
|
815
|
+
end
|
816
|
+
|
817
|
+
nil
|
818
|
+
end
|
819
|
+
|
820
|
+
def __init_fields__()
|
821
|
+
|
822
|
+
self.lock = nil
|
823
|
+
self.pending = nil
|
824
|
+
self.executor = nil
|
825
|
+
self.idle = nil
|
826
|
+
|
827
|
+
nil
|
828
|
+
end
|
829
|
+
|
830
|
+
|
831
|
+
end
|
832
|
+
Collector.unlazy_statics
|
833
|
+
|
834
|
+
def self.TimeoutListener; TimeoutListener; end
|
835
|
+
##
|
836
|
+
# Timeout expiry handler
|
837
|
+
|
838
|
+
class TimeoutListener < ::DatawireQuarkCore::QuarkObject
|
839
|
+
extend ::DatawireQuarkCore::Static
|
840
|
+
|
841
|
+
static quark_concurrent_TimeoutListener_ref: -> { nil }
|
842
|
+
|
843
|
+
|
844
|
+
|
845
|
+
def initialize()
|
846
|
+
self.__init_fields__
|
847
|
+
|
848
|
+
nil
|
849
|
+
end
|
850
|
+
|
851
|
+
|
852
|
+
|
853
|
+
|
854
|
+
def onTimeout(timeout)
|
855
|
+
raise NotImplementedError, '`TimeoutListener.onTimeout` is an abstract method'
|
856
|
+
|
857
|
+
nil
|
858
|
+
end
|
859
|
+
|
860
|
+
def __init_fields__()
|
861
|
+
|
862
|
+
|
863
|
+
nil
|
864
|
+
end
|
865
|
+
|
866
|
+
|
867
|
+
end
|
868
|
+
TimeoutListener.unlazy_statics
|
869
|
+
|
870
|
+
def self.TimeoutExpiry; TimeoutExpiry; end
|
871
|
+
##
|
872
|
+
# Timeout expiry event
|
873
|
+
|
874
|
+
class TimeoutExpiry < ::DatawireQuarkCore::QuarkObject
|
875
|
+
attr_accessor :timeout, :listener
|
876
|
+
extend ::DatawireQuarkCore::Static
|
877
|
+
|
878
|
+
static quark_concurrent_TimeoutExpiry_ref: -> { nil }
|
879
|
+
|
880
|
+
|
881
|
+
|
882
|
+
def initialize(timeout, listener)
|
883
|
+
|
884
|
+
self.__init_fields__
|
885
|
+
(self).timeout = timeout
|
886
|
+
(self).listener = listener
|
887
|
+
|
888
|
+
nil
|
889
|
+
end
|
890
|
+
|
891
|
+
|
892
|
+
|
893
|
+
|
894
|
+
def getContext()
|
895
|
+
|
896
|
+
return (self).timeout
|
897
|
+
|
898
|
+
nil
|
899
|
+
end
|
900
|
+
|
901
|
+
def fireEvent()
|
902
|
+
|
903
|
+
(self).listener.onTimeout((self).timeout)
|
904
|
+
|
905
|
+
nil
|
906
|
+
end
|
907
|
+
|
908
|
+
def _getClass()
|
909
|
+
|
910
|
+
return "quark.concurrent.TimeoutExpiry"
|
911
|
+
|
912
|
+
nil
|
913
|
+
end
|
914
|
+
|
915
|
+
def _getField(name)
|
916
|
+
|
917
|
+
if ((name) == ("timeout"))
|
918
|
+
return (self).timeout
|
919
|
+
end
|
920
|
+
if ((name) == ("listener"))
|
921
|
+
return (self).listener
|
922
|
+
end
|
923
|
+
return nil
|
924
|
+
|
925
|
+
nil
|
926
|
+
end
|
927
|
+
|
928
|
+
def _setField(name, value)
|
929
|
+
|
930
|
+
if ((name) == ("timeout"))
|
931
|
+
(self).timeout = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.Timeout }
|
932
|
+
end
|
933
|
+
if ((name) == ("listener"))
|
934
|
+
(self).listener = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.TimeoutListener }
|
935
|
+
end
|
936
|
+
|
937
|
+
nil
|
938
|
+
end
|
939
|
+
|
940
|
+
def __init_fields__()
|
941
|
+
|
942
|
+
self.timeout = nil
|
943
|
+
self.listener = nil
|
944
|
+
|
945
|
+
nil
|
946
|
+
end
|
947
|
+
|
948
|
+
|
949
|
+
end
|
950
|
+
TimeoutExpiry.unlazy_statics
|
951
|
+
|
952
|
+
def self.Timeout; Timeout; end
|
953
|
+
##
|
954
|
+
# Timeout
|
955
|
+
|
956
|
+
class Timeout < ::Quark.quark.concurrent.EventContext
|
957
|
+
attr_accessor :timeout, :lock, :listener
|
958
|
+
extend ::DatawireQuarkCore::Static
|
959
|
+
|
960
|
+
static quark_concurrent_Timeout_ref: -> { nil }
|
961
|
+
|
962
|
+
|
963
|
+
|
964
|
+
def initialize(timeout)
|
965
|
+
|
966
|
+
super()
|
967
|
+
(self).timeout = timeout
|
968
|
+
(self).listener = ::DatawireQuarkCore.cast(nil) { ::Quark.quark.concurrent.TimeoutListener }
|
969
|
+
(self).lock = ::DatawireQuarkCore::Lock.new()
|
970
|
+
|
971
|
+
nil
|
972
|
+
end
|
973
|
+
|
974
|
+
|
975
|
+
|
976
|
+
|
977
|
+
def start(listener)
|
978
|
+
|
979
|
+
(self).listener = listener
|
980
|
+
delay = (self).timeout
|
981
|
+
::Quark.quark.concurrent.Context.runtime().schedule(self, delay)
|
982
|
+
|
983
|
+
nil
|
984
|
+
end
|
985
|
+
|
986
|
+
def cancel()
|
987
|
+
|
988
|
+
(self).lock.acquire()
|
989
|
+
(self).listener = ::DatawireQuarkCore.cast(nil) { ::Quark.quark.concurrent.TimeoutListener }
|
990
|
+
(self).lock.release()
|
991
|
+
|
992
|
+
nil
|
993
|
+
end
|
994
|
+
|
995
|
+
def onExecute(runtime)
|
996
|
+
|
997
|
+
(self).lock.acquire()
|
998
|
+
if (((self).listener) != (nil))
|
999
|
+
((self)._context).collector.put(::Quark.quark.concurrent.TimeoutExpiry.new(self, (self).listener))
|
1000
|
+
(self).listener = ::DatawireQuarkCore.cast(nil) { ::Quark.quark.concurrent.TimeoutListener }
|
1001
|
+
end
|
1002
|
+
(self).lock.release()
|
1003
|
+
|
1004
|
+
nil
|
1005
|
+
end
|
1006
|
+
|
1007
|
+
def _getClass()
|
1008
|
+
|
1009
|
+
return "quark.concurrent.Timeout"
|
1010
|
+
|
1011
|
+
nil
|
1012
|
+
end
|
1013
|
+
|
1014
|
+
def _getField(name)
|
1015
|
+
|
1016
|
+
if ((name) == ("_context"))
|
1017
|
+
return (self)._context
|
1018
|
+
end
|
1019
|
+
if ((name) == ("timeout"))
|
1020
|
+
return (self).timeout
|
1021
|
+
end
|
1022
|
+
if ((name) == ("lock"))
|
1023
|
+
return (self).lock
|
1024
|
+
end
|
1025
|
+
if ((name) == ("listener"))
|
1026
|
+
return (self).listener
|
1027
|
+
end
|
1028
|
+
return nil
|
1029
|
+
|
1030
|
+
nil
|
1031
|
+
end
|
1032
|
+
|
1033
|
+
def _setField(name, value)
|
1034
|
+
|
1035
|
+
if ((name) == ("_context"))
|
1036
|
+
(self)._context = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.Context }
|
1037
|
+
end
|
1038
|
+
if ((name) == ("timeout"))
|
1039
|
+
(self).timeout = ::DatawireQuarkCore.cast(value) { ::Float }
|
1040
|
+
end
|
1041
|
+
if ((name) == ("lock"))
|
1042
|
+
(self).lock = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::Lock }
|
1043
|
+
end
|
1044
|
+
if ((name) == ("listener"))
|
1045
|
+
(self).listener = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.TimeoutListener }
|
1046
|
+
end
|
1047
|
+
|
1048
|
+
nil
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
def __init_fields__()
|
1052
|
+
|
1053
|
+
super
|
1054
|
+
self.timeout = nil
|
1055
|
+
self.lock = nil
|
1056
|
+
self.listener = nil
|
1057
|
+
|
1058
|
+
nil
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
|
1062
|
+
end
|
1063
|
+
Timeout.unlazy_statics
|
1064
|
+
|
1065
|
+
def self.TLSContextInitializer; TLSContextInitializer; end
|
1066
|
+
##
|
1067
|
+
# internal
|
1068
|
+
|
1069
|
+
class TLSContextInitializer < ::DatawireQuarkCore::QuarkObject
|
1070
|
+
extend ::DatawireQuarkCore::Static
|
1071
|
+
|
1072
|
+
static quark_concurrent_TLSContextInitializer_ref: -> { nil }
|
1073
|
+
|
1074
|
+
|
1075
|
+
|
1076
|
+
def initialize()
|
1077
|
+
self.__init_fields__
|
1078
|
+
|
1079
|
+
nil
|
1080
|
+
end
|
1081
|
+
|
1082
|
+
|
1083
|
+
|
1084
|
+
|
1085
|
+
def getValue()
|
1086
|
+
|
1087
|
+
return ::Quark.quark.concurrent.Context.new(::Quark.quark.concurrent.Context.global())
|
1088
|
+
|
1089
|
+
nil
|
1090
|
+
end
|
1091
|
+
|
1092
|
+
def _getClass()
|
1093
|
+
|
1094
|
+
return "quark.concurrent.TLSContextInitializer"
|
1095
|
+
|
1096
|
+
nil
|
1097
|
+
end
|
1098
|
+
|
1099
|
+
def _getField(name)
|
1100
|
+
|
1101
|
+
return nil
|
1102
|
+
|
1103
|
+
nil
|
1104
|
+
end
|
1105
|
+
|
1106
|
+
def _setField(name, value)
|
1107
|
+
|
1108
|
+
nil
|
1109
|
+
|
1110
|
+
nil
|
1111
|
+
end
|
1112
|
+
|
1113
|
+
def __init_fields__()
|
1114
|
+
|
1115
|
+
|
1116
|
+
nil
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
|
1120
|
+
end
|
1121
|
+
TLSContextInitializer.unlazy_statics
|
1122
|
+
|
1123
|
+
def self.Context; Context; end
|
1124
|
+
##
|
1125
|
+
# The logical stack for async stuff.
|
1126
|
+
|
1127
|
+
class Context < ::DatawireQuarkCore::QuarkObject
|
1128
|
+
attr_accessor :_parent, :_runtime, :collector
|
1129
|
+
extend ::DatawireQuarkCore::Static
|
1130
|
+
|
1131
|
+
static _global: -> { nil }
|
1132
|
+
static _current: -> { ::DatawireQuarkCore::TLS.new(::Quark.quark.concurrent.TLSContextInitializer.new()) }
|
1133
|
+
static quark_concurrent_Context_ref: -> { nil }
|
1134
|
+
|
1135
|
+
|
1136
|
+
|
1137
|
+
def initialize(parent)
|
1138
|
+
|
1139
|
+
self.__init_fields__
|
1140
|
+
(self)._parent = parent
|
1141
|
+
if ((parent) == (nil))
|
1142
|
+
(self)._runtime = ::Quark.quark.spi.RuntimeFactory.factory.makeRuntime()
|
1143
|
+
(self).collector = ::Quark.quark.concurrent.Collector.new()
|
1144
|
+
else
|
1145
|
+
(self)._runtime = (parent)._runtime
|
1146
|
+
(self).collector = (parent).collector
|
1147
|
+
end
|
1148
|
+
|
1149
|
+
nil
|
1150
|
+
end
|
1151
|
+
|
1152
|
+
|
1153
|
+
|
1154
|
+
|
1155
|
+
def self.current()
|
1156
|
+
|
1157
|
+
return ::Quark.quark.concurrent.Context._current.getValue()
|
1158
|
+
|
1159
|
+
nil
|
1160
|
+
end
|
1161
|
+
|
1162
|
+
def self.global()
|
1163
|
+
|
1164
|
+
if ((::Quark.quark.concurrent.Context._global) == (nil))
|
1165
|
+
::Quark.quark.concurrent.Context._global = ::Quark.quark.concurrent.Context.new(nil)
|
1166
|
+
end
|
1167
|
+
return ::Quark.quark.concurrent.Context._global
|
1168
|
+
|
1169
|
+
nil
|
1170
|
+
end
|
1171
|
+
|
1172
|
+
def self.runtime()
|
1173
|
+
|
1174
|
+
return (::Quark.quark.concurrent.Context.current())._runtime
|
1175
|
+
|
1176
|
+
nil
|
1177
|
+
end
|
1178
|
+
|
1179
|
+
def self.swap(c)
|
1180
|
+
|
1181
|
+
::Quark.quark.concurrent.Context._current.setValue(c)
|
1182
|
+
|
1183
|
+
nil
|
1184
|
+
end
|
1185
|
+
|
1186
|
+
def _getClass()
|
1187
|
+
|
1188
|
+
return "quark.concurrent.Context"
|
1189
|
+
|
1190
|
+
nil
|
1191
|
+
end
|
1192
|
+
|
1193
|
+
def _getField(name)
|
1194
|
+
|
1195
|
+
if ((name) == ("_global"))
|
1196
|
+
return ::Quark.quark.concurrent.Context._global
|
1197
|
+
end
|
1198
|
+
if ((name) == ("_current"))
|
1199
|
+
return ::Quark.quark.concurrent.Context._current
|
1200
|
+
end
|
1201
|
+
if ((name) == ("_parent"))
|
1202
|
+
return (self)._parent
|
1203
|
+
end
|
1204
|
+
if ((name) == ("_runtime"))
|
1205
|
+
return (self)._runtime
|
1206
|
+
end
|
1207
|
+
if ((name) == ("collector"))
|
1208
|
+
return (self).collector
|
1209
|
+
end
|
1210
|
+
return nil
|
1211
|
+
|
1212
|
+
nil
|
1213
|
+
end
|
1214
|
+
|
1215
|
+
def _setField(name, value)
|
1216
|
+
|
1217
|
+
if ((name) == ("_global"))
|
1218
|
+
::Quark.quark.concurrent.Context._global = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.Context }
|
1219
|
+
end
|
1220
|
+
if ((name) == ("_current"))
|
1221
|
+
::Quark.quark.concurrent.Context._current = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::TLS }
|
1222
|
+
end
|
1223
|
+
if ((name) == ("_parent"))
|
1224
|
+
(self)._parent = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.Context }
|
1225
|
+
end
|
1226
|
+
if ((name) == ("_runtime"))
|
1227
|
+
(self)._runtime = ::DatawireQuarkCore.cast(value) { ::Quark.quark.Runtime }
|
1228
|
+
end
|
1229
|
+
if ((name) == ("collector"))
|
1230
|
+
(self).collector = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.Collector }
|
1231
|
+
end
|
1232
|
+
|
1233
|
+
nil
|
1234
|
+
end
|
1235
|
+
|
1236
|
+
def __init_fields__()
|
1237
|
+
|
1238
|
+
self._parent = nil
|
1239
|
+
self._runtime = nil
|
1240
|
+
self.collector = nil
|
1241
|
+
|
1242
|
+
nil
|
1243
|
+
end
|
1244
|
+
|
1245
|
+
|
1246
|
+
end
|
1247
|
+
Context.unlazy_statics
|
1248
|
+
end # module Concurrent
|
1249
|
+
end # module Quark
|
1250
|
+
end # module Quark
|