• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mlange-42 / arche-model / 4743284546

19 Apr 2023 12:28PM CUT coverage: 97.196%. Remained the same
4743284546

push

github

GitHub
Upgrade dependencies to latest (#40)

520 of 535 relevant lines covered (97.2%)

99.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/system/callback_termination.go
1
package system
2

3
import (
4
        "github.com/mlange-42/arche-model/resource"
5
        "github.com/mlange-42/arche/ecs"
6
        "github.com/mlange-42/arche/generic"
7
)
8

9
// CallbackTermination system.
10
//
11
// Terminates a model run according to the return value of a callback function.
12
//
13
// Expects a resource of type [model.Termination].
14
type CallbackTermination struct {
15
        Callback func(t int64) bool // The callback. ends the simulation when it returns true.
16
        termRes  generic.Resource[resource.Termination]
17
        step     int64
18
}
19

20
// Initialize the system
21
func (s *CallbackTermination) Initialize(w *ecs.World) {
2✔
22
        s.termRes = generic.NewResource[resource.Termination](w)
2✔
23
        s.step = 0
2✔
24
}
2✔
25

26
// Update the system
27
func (s *CallbackTermination) Update(w *ecs.World) {
200✔
28
        term := s.termRes.Get()
200✔
29

200✔
30
        if s.Callback(s.step) {
202✔
31
                term.Terminate = true
2✔
32
        }
2✔
33
        s.step++
200✔
34
}
35

36
// Finalize the system
37
func (s *CallbackTermination) Finalize(w *ecs.World) {}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc