| 1 | package control |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "errors" |
| 6 | |
| 7 | "reasonix/internal/session" |
| 8 | ) |
| 9 | |
| 10 | func goalRuntimeRetired(c *Controller, service *session.Service, runtime *session.Runtime, settled bool) bool { |
| 11 | current, ok := service.Runtime(runtime.Ref()) |
| 12 | if settled && !c.Running() && ok && current == runtime { |
| 13 | if err := service.Close(context.Background(), runtime.Ref()); errors.Is(err, session.ErrRuntimeBusy) || errors.Is(err, session.ErrRuntimeBound) { |
| 14 | return false |
| 15 | } |
| 16 | current, ok = service.Runtime(runtime.Ref()) |
| 17 | } |
| 18 | return !ok || current != runtime |
| 19 | } |
| 20 |