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

Eliminate dependency on Swing and call to invokeLater #345

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JaroslavTulach
Copy link
Contributor

There is a support for reporting progress of long running operations via the HeapProgress class. However this class directly calls into AWT which would better be avoided if the librrary is supposed to be used in a headless mode.

This PR keeps the compatibility with existing HeapProgress behavior, yet it avoid the AWT interactions until somebody access HeapProgress.getProgress() model.

@@ -51,16 +51,20 @@ synchronized static void register(Listener onChange) {
}
}

synchronized static void notifyUpdates(Handle h, int type) {
private synchronized static void notifyUpdates(Handle h, Type type) {
Copy link

Choose a reason for hiding this comment

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

how bout ?

private synchronized static void notifyUpdates(Handle h, BiConsumer<Listener, Handle> c) {
    for (Listener onChange : listeners) {
         c.accept(onChange, h);
     }
}

and then call it like

    @Override
    public void close() {
        notifyUpdates(this, 2);
        notifyUpdates(this, Listener::finished);
    }

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.

None yet

2 participants