behavior_machines 0.1.0 → 0.2.0
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/README.md +2 -1
- data/lib/behavior_machines/engine.rb +11 -3
- data/lib/behavior_machines/tree.rb +2 -1
- data/lib/behavior_machines/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9a83e1e8b54ae643e0763d07afbf5b34f5ddf80790c55e57a958f82754a8328f
|
|
4
|
+
data.tar.gz: 4df17f639b4f87c83473508e5d44eac058f1e9ced1ebce87a630c0a27498818f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c3bb6e3ba9b6f58c861193cdc944c425167544425531b60d06ea31c2a5d7b6bd3354101918f22d3593ae26cb27399058eedf9f668316fa22da1d0815006458a2
|
|
7
|
+
data.tar.gz: fe002a3c84e4dce7e8d8049762f062bcc31f39c17a52c4b02921d2a2e46d42bf6c40dab32d63cd0155fd8385b0e27033920d37181c27609ecf4ee63cc1d9846d
|
data/README.md
CHANGED
|
@@ -68,7 +68,8 @@ compiles them.
|
|
|
68
68
|
Durations are seconds. The clock is an Integer count of nanoseconds, passed as
|
|
69
69
|
`now:` and defaulting to `BehaviorMachines.now` (monotonic).
|
|
70
70
|
`tree.next_deadline` returns when a running `sleep` or `timeout` next needs a
|
|
71
|
-
tick, so a host can sleep until then.
|
|
71
|
+
tick, so a host can sleep until then. A looping decorator that finished a run
|
|
72
|
+
reports that tick's time, so its next run is due at once.
|
|
72
73
|
|
|
73
74
|
## Errors
|
|
74
75
|
|
|
@@ -441,7 +441,7 @@ module BehaviorMachines
|
|
|
441
441
|
end
|
|
442
442
|
|
|
443
443
|
# Repeat, RetryUntilSuccessful, and KeepRunningUntilFailure: at most one
|
|
444
|
-
# finished child run per tick.
|
|
444
|
+
# finished child run per tick; the next run is due at once.
|
|
445
445
|
class LoopSlot < Slot
|
|
446
446
|
def initialize(id, child, again_on, limit)
|
|
447
447
|
super(id)
|
|
@@ -449,20 +449,28 @@ module BehaviorMachines
|
|
|
449
449
|
@again_on = again_on
|
|
450
450
|
@limit = limit
|
|
451
451
|
@runs = 0
|
|
452
|
+
@due = nil
|
|
452
453
|
end
|
|
453
454
|
|
|
454
455
|
private
|
|
455
456
|
|
|
456
457
|
def step(run, now, _starting)
|
|
458
|
+
@due = nil
|
|
457
459
|
return @again_on if @limit&.zero?
|
|
458
460
|
|
|
459
461
|
status = @child.tick(run, now)
|
|
460
462
|
return status if status == :running
|
|
461
463
|
return finish(status) unless status == @again_on
|
|
462
|
-
return
|
|
464
|
+
return again(now) if @limit.nil?
|
|
463
465
|
return finish(status) if @runs + 1 == @limit
|
|
464
466
|
|
|
465
467
|
@runs += 1
|
|
468
|
+
again(now)
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
# A run finished and the next waits for a tick: due at once.
|
|
472
|
+
def again(now)
|
|
473
|
+
@due = now
|
|
466
474
|
:running
|
|
467
475
|
end
|
|
468
476
|
|
|
@@ -476,7 +484,7 @@ module BehaviorMachines
|
|
|
476
484
|
@runs = 0
|
|
477
485
|
end
|
|
478
486
|
|
|
479
|
-
def running_deadline = @child.next_deadline
|
|
487
|
+
def running_deadline = earliest([@due, @child.next_deadline])
|
|
480
488
|
end
|
|
481
489
|
end
|
|
482
490
|
end
|
|
@@ -53,7 +53,8 @@ module BehaviorMachines
|
|
|
53
53
|
@engine.running?
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
# The earliest time, in nanoseconds, a running Sleep or Timeout will fire
|
|
56
|
+
# The earliest time, in nanoseconds, a running Sleep or Timeout will fire,
|
|
57
|
+
# or a looping decorator wants its next run (already due).
|
|
57
58
|
def next_deadline
|
|
58
59
|
check_idle
|
|
59
60
|
@engine.next_deadline
|