ctongfei / progressbar

Terminal-based progress bar for Java / JVM
http://tongfei.me/progressbar/
MIT License
1.08k stars 103 forks source link

Feature request : await()/await(duration) methods #96

Closed jvmlet closed 3 years ago

jvmlet commented 3 years ago

Would you please add await capability to the progress bar :

c'tor :
latch = CountDownLatch(initialMax)

on stepBy :
 latch.countDown(n times)

and
public void  await(){
latch .await()
}
publiv void  await(duration){
latch .await(duration)
}
ctongfei commented 3 years ago

Hi @jvmlet ! I don't fully understand what you mean here: what is the semantics of await?

jvmlet commented 3 years ago

Blocks until latch reaches 0 ( 100% progress).

ctongfei commented 3 years ago

Blocking the main thread until the progress finishes?

jvmlet commented 3 years ago

Yes

ctongfei commented 3 years ago

Should this be a progress bar's job? I suppose that when a user starts a task that is tracked by a progress bar, one can always await on that task instead of on the progress bar.

jvmlet commented 3 years ago

You are right, but in most cases completion is tracked by count down latch. I thought that if progress bar has this count, it would be easier to do this via progress bar

ctongfei commented 3 years ago

In the spirit of decoupling and modularizing software modules, I have decided not to implement this feature since this is out of scope of a progress bar. Thanks @jvmlet for the suggestion.