Repository navigation
Introduce new Component class - #705
Conversation
|
|
||
| for (const IReadyCondition* ready_condition : ready_conditions_) | ||
| { | ||
| const osal::OsalReturnType result = ready_condition->wait(handle_.value()); |
There was a problem hiding this comment.
Currently we have one overall ready timeout for the component.
if we had multiple ready conditions, I think this would mean all ready condition must be fulfilled within the ready_timeout. So it would not be that each ready condition can take the full ready timeout.
This makes me think that it could make sense to move the timeout checking in the component. Same for the shutdown timeout
There was a problem hiding this comment.
I think we could pass a timeout into the ready condition when it is called (rather than storing it). Then on each iteration through the list the component could calculate the remaining time until the overall deadline.
There was a problem hiding this comment.
Actually I think it would be nice to pass a struct/class like Go contexts which has both a deadline and a stop token.
Then the ready condition can stop either when the deadline expires or cancellation is requested.
There was a problem hiding this comment.
Timeouts will be implemented in a separate pull request. :))
|
|
||
| if (process.pid > 0) | ||
| { | ||
| if (kill(process.pid, SIGTERM) == 0) |
There was a problem hiding this comment.
I think we'll need to decide where the timeout monitoring takes place for the shutdown and the escalation to SIGKILL in case of timeout
There was a problem hiding this comment.
Timeouts will be implemented in a later pull request.
ProcessInfoNode and ProcessLauncherComponent class
Follow the naming conventions.
This is based on the diagram introduced in eclipse-score#736.
While `operator()` was slightly less code, the methods had to be public for it to work.
For invalid handles, we should move to the terminated state immediately, rather than waiting for a termination event.
This can be reintroduced once it is decided how a force stop is triggered. Link: https://github.com/eclipse-score/lifecycle/pull/705/changes#r4154237710
Just switch using if statements rather than a separate implementation for each state. This makes it more obvious how things work with concurrency.
|
Documentation preview for this pull request is available at: |
| lock.unlock(); | ||
| for (const IReadyCondition& ready_condition : ready_conditions_) | ||
| { | ||
| if (!ready_condition.wait(stop_activation.get_token(), handle).has_value()) |
There was a problem hiding this comment.
The ready_condition gets a copy of the handle, so it will not actually observe if the pid was set to -1 if the process terminated inbetween. However, passing the actual reference to the handle from the state would lead to data race since there is no lock and oshandler thread also modifies it
There was a problem hiding this comment.
I agree. However, no ready conditions rely on the PID at the moment.
Maybe we can leave this as an open point for now, to avoid blocking the pull request?
If so, I'll create a separate issue to address this :))
| return RequestState::kSuccess; | ||
| } | ||
|
|
||
| SCORE_LANGUAGE_FUTURECPP_UNREACHABLE_MESSAGE("If stop was not requested, then state must still be StartingState"); |
There was a problem hiding this comment.
Is this actually reachable for self-terminating processes where no stop was requested in tryHandleTermination?
There was a problem hiding this comment.
When no stop is requested, the state is not changed. So, if the activate method is still running, then the state must still be starting. If the process terminates after it enters the ready state, activate has already returned so the assertion is not reached
| if (self_terminating_ && status == 0) | ||
| { | ||
| return RequestState::kWaiting; | ||
| } |
There was a problem hiding this comment.
How do we move from Starting->Ready for a self-terminating process that has ready condition ProcessState:Terminated?
Is there a ReadyCondition currently missing for this case?
There was a problem hiding this comment.
Yes, the ready condition is missing because we were waiting for #738. As a separate pull request we can adapt that code to implement the ready condition interface
|
This PR introduces new classes which are not yet used by the production code. |
Start, stop, force stop, and ready conditions are now implemented as strategies which plug in to a central
Componentclass.The only interaction between these classes is a tiny
Handlestruct, which identifies the child process to act upon.Ideally, the handle will stay internal to the
Component, and higher level classes such asProcessGroupManagerand theGraphwill have no knowledge of the underlying process.This new architecture should improve:
ProcessInfoNodehaving a mixture of process- and component-level code.ProcessLauncheralso having code for process termination.As a start, this pull request just introduces the new classes, and has them call the existing
ProcessLauncherfrom its original location.Once the new component class is ready, we can change the
Graphto start using it in place ofProcessInfoNode. Currently it is unused outside of tests.Finally, we will clean up by moving the old code into its new locations (rather than just calling it).