Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RepeatingTaskThread #36

Merged
merged 30 commits into from
Nov 12, 2024
Merged

RepeatingTaskThread #36

merged 30 commits into from
Nov 12, 2024

Conversation

TomaszTB
Copy link
Contributor

@TomaszTB TomaszTB commented Nov 4, 2024

Replacement for RestartableThread and RestartableThrottledThread!

@TomaszTB TomaszTB force-pushed the feature/repeating-task-thread branch from ea23027 to ccad200 Compare November 4, 2024 17:29
*
* @return {@code false} if {@link #kill()} or {@link #blockingKill()} has been called. {@code true} otherwise.
*/
public boolean isRunning()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is extremely similar to isAlive(). Should it be kept?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you use it anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I can't think of a place where I'd use it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isRunning() and isRepeating are not intuitive. I would just provide getCompleted and getRemaining

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove isRunning, but I'll probably keep isRepeating package private to use in tests. It is handy there

@TomaszTB TomaszTB requested a review from calvertdw November 4, 2024 18:44
@TomaszTB TomaszTB requested review from calvertdw and ds58 November 5, 2024 17:08
* remains interrupted.
*/
// Uses ThreadTools.parkAtLeast, which will not throw InterruptedException, but
// will return early when this thread is interrupted.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is false, because parkAtLeast loops until the desired time has elapsed. It might just free spin if parkNanos is returning immediately due to the interrupt. We should probably fix that haha.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed this in #41

// clear interrupted status
interrupted();
// clears interrupted status from
if (interrupted() && executionState.getScheduled() == 0L)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this behavior. But what about clearing the interrupt status somewhere else, so it doesn't depend on whether the thread is throttled?

@calvertdw calvertdw force-pushed the feature/repeating-task-thread branch from 6e66dd0 to aa83295 Compare November 12, 2024 18:42
@ds58 ds58 self-requested a review November 12, 2024 18:52
@calvertdw calvertdw force-pushed the feature/repeating-task-thread branch from 609561c to 77b5148 Compare November 12, 2024 20:12
@ds58 ds58 self-requested a review November 12, 2024 21:57
@calvertdw calvertdw merged commit 1b09405 into develop Nov 12, 2024
2 checks passed
@calvertdw calvertdw deleted the feature/repeating-task-thread branch November 12, 2024 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants