Repository navigation
Create API for global progress listeners - #80
Conversation
204eddb to
43df18b
Compare
ctrueden
left a comment
There was a problem hiding this comment.
The changes to Task to make it more robust are great!
But I'm not convinced about the Progress.addGlobalListener feature. What is a concrete use case where this is needed? I can't think of one.
Furthermore, the scijava-progress concept is very general, beyond only scijava-ops. You could in theory subscribe to updates to anything, right? So then this global listener thing really only listens to everything, with no way to narrow it to particular scopes. I feel like, if we are going to allow listeners that are broader than individual objects, we may want to allow listening to classes of objects, and then if you listen to Object you listen to everything. But now we are starting to reinvent scijava-common's org.scijava.event package, which already has that functionality in its event pub/sub model. Maybe it's worth considering if/how these two subsystems could be combined?
The original use case that I was thinking of was a Progress UI, allowing the user to keep track of Ops run in scripts and potentially also run graphically through a search bar. I don't know how you'd otherwise allow internal mechanisms to listen to progress - you'd probably need a callbacks mechanism... The other use case here is convenience - the current API requires you to register the
ops.op("foo.bar").arity1().input(foo).output(bar).compute();
It was this second use case that I encountered when I updated the tutorials, and made me want to add this functionality.
That's a good point, although I think we may still need the functionality to subscribe globally? |
We might want to add a description to each Task, to tell them apart if a single listener listens to multiple tasks
43df18b to
c7f3a94
Compare
It's nice to have a simple default, instead of always creating your own
|
I merged these changes because I think it is an improvement in usability. @ctrueden said:
I think this is still a fair point, but I don't want to spend time right now thinking about it. I'd rather think about it when we have a need for the |
This PR adds API for introducing global progress listeners, in anticipation of end-users or external framework wanting to monitor progress without registering every Op.
Beyond the new global API, this PR also introduces additional changes needed to make
Tasks more informative and robust. A list of the changes is provided below:descriptionfield is added to theTaskclass to make it clearer whichTasks describe a given execution. To support Ops,AbstractRichOp.toString()now provides a clear, more informative name.Taskcompletes only once.longdefining the number of steps, instead of anint- this makes the step math more uniform.