mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-13 15:00:42 -08:00
Simplify code relating to UI thread synchronization
* java/org/gnu/emacs/EmacsContextMenu.java (display): * java/org/gnu/emacs/EmacsDialog.java (display): * java/org/gnu/emacs/EmacsService.java (getEmacsView) (getLocationOnScreen, getClipboardManager) (requestDirectoryAccess): Replace manual synchronization within Runnable objects by usage of FutureTask. (syncRunnable): Accept FutureTask<V> in place of Runnables, and obtain and return results from calls to its get method.
This commit is contained in:
parent
fe2b68d405
commit
94e3d11593
3 changed files with 118 additions and 149 deletions
|
|
@ -22,6 +22,9 @@ package org.gnu.emacs;
|
|||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
|
||||
import android.content.Context;
|
||||
|
|
@ -388,26 +391,18 @@ public final class EmacsDialog implements DialogInterface.OnDismissListener
|
|||
public boolean
|
||||
display ()
|
||||
{
|
||||
Runnable runnable;
|
||||
final EmacsHolder<Boolean> rc;
|
||||
FutureTask<Boolean> task;
|
||||
|
||||
rc = new EmacsHolder<Boolean> ();
|
||||
rc.thing = false;
|
||||
runnable = new Runnable () {
|
||||
task = new FutureTask<Boolean> (new Callable<Boolean> () {
|
||||
@Override
|
||||
public void
|
||||
run ()
|
||||
public Boolean
|
||||
call ()
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
rc.thing = display1 ();
|
||||
notify ();
|
||||
}
|
||||
return display1 ();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
EmacsService.syncRunnable (runnable);
|
||||
return rc.thing;
|
||||
return EmacsService.<Boolean>syncRunnable (task);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue