Repeat Task until Condition is met
See original GitHub issueIt would be nice to have repeating tasks in the chain. something like this:
newChain().repeat(c-> c.repeat(c->c.delay(10, TimeUnit.SECONDS).sync(this::updateSigns),6).async(this::updateDB),-1)
would do something like this
while(true){
for(int i = 0;i<6;i++){
wait(10, second)
(sync) updateSigns();
}
(async)updateDB();
}
(repeat would take a lambda that does stuff with a new chain that will be executed every time repeat is called) Don’t really know if the way I outlined that api is a good thing to do something like that, but I think the general concept of repeating some parts of a chain n (or -1 for endless) times.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How to repeat loop until condition is met? While or For Loop?
I wanted to create a loop until a certain condition is met, for example lets say I have constant x, that is included...
Read more >Repeat/Until Block Loops - Elements Docs
Repeat /Until Block Loops. The repeat / until loop is a loop that executes a block of statements repeatedly, until a given condition...
Read more >Ansible Retry Examples - Retry a task until condition met
Ansible Retry until can rerun the task only until the defined number of retries. It cannot run the task forever until the condition...
Read more >Run a repeating task until a condition is met - SpigotMC
Hey! I was wondering how I would run a task over and over, interval needs to be fast, until a condition is met?...
Read more >Easily Repeat Tasks Using Loops - Learn Python Basics
There are also times when the number of repetitions does not matter, and you want to repeat the code until a certain condition...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh I just noticed the infinite loop outer layer.
That’s not something i want to do with TC, as TC needs the ability to shut down, and there’s no clear way to define how to shut that down.
Thats something easy to just wrap in Bukkits repeating task outer wrapper, then TC control the inner actions.
This would have to look like there’s 2 things really being asked for here.
.chain((c) -> { })
that allows you to insert tasks into the chain as part of a callback, which would have to execute IMMEDIATELY to build the chain.So that design isn’t good, it would need to be:
So TC can read the tasks out of that and clone them into this one;
Then the 2nd request is, a way to say “run this sequence of tasks X times”
I feel like the repeating part is unnecessary as it can be calculated easily by the caller as:
So yeah i don’t see repeating as a beneficial API. But using another chain as a template, maybe so.