예제 #1
0
파일: TObject.java 프로젝트: leobm/teavm
 @Override
 public void interrupted() {
   if (performed) {
     return;
   }
   performed = true;
   if (timerId >= 0) {
     Platform.killSchedule(timerId);
     timerId = -1;
   }
   Platform.postpone(() -> callback.error(new TInterruptedException()));
 }
예제 #2
0
파일: TObject.java 프로젝트: leobm/teavm
 static void monitorEnterWait(
     final TObject o, final int count, final AsyncCallback<Void> callback) {
   final TThread thread = TThread.currentThread();
   if (o.monitor == null) {
     o.monitor = new Monitor();
     TThread.setCurrentThread(thread);
     o.monitor.count += count;
     callback.complete(null);
     return;
   } else if (o.monitor.owner == null) {
     o.monitor.owner = thread;
     TThread.setCurrentThread(thread);
     o.monitor.count += count;
     callback.complete(null);
     return;
   }
   o.monitor.enteringThreads.add(
       () -> {
         TThread.setCurrentThread(thread);
         o.monitor.owner = thread;
         o.monitor.count += count;
         callback.complete(null);
       });
 }