Пример #1
0
 @Override
 protected Object clone() throws TCloneNotSupportedException {
   if (!(this instanceof TCloneable)
       && Platform.getPlatformObject(this).getPlatformClass().getMetadata().getArrayItem()
           == null) {
     throw new TCloneNotSupportedException();
   }
   Object result = Platform.clone(this);
   Platform.getPlatformObject(result).setId(Platform.nextObjectId());
   return result;
 }
Пример #2
0
 @Override
 public void interrupted() {
   if (performed) {
     return;
   }
   performed = true;
   if (timerId >= 0) {
     Platform.killSchedule(timerId);
     timerId = -1;
   }
   Platform.postpone(() -> callback.error(new TInterruptedException()));
 }
Пример #3
0
  @Sync
  static void monitorExit(final TObject o, int count) {
    if (o.isEmptyMonitor() || o.monitor.owner != TThread.currentThread()) {
      throw new TIllegalMonitorStateException();
    }
    o.monitor.count -= count;
    if (o.monitor.count > 0) {
      return;
    }

    o.monitor.owner = null;
    if (!o.monitor.enteringThreads.isEmpty()) {
      Platform.postpone(
          () -> {
            if (o.isEmptyMonitor() || o.monitor.owner != null) {
              return;
            }
            if (!o.monitor.enteringThreads.isEmpty()) {
              o.monitor.enteringThreads.remove().run();
            }
          });
    } else {
      o.isEmptyMonitor();
    }
  }
Пример #4
0
 public final void waitImpl(long timeout, int nanos, final AsyncCallback<Void> callback) {
   final NotifyListenerImpl listener = new NotifyListenerImpl(this, callback, monitor.count);
   monitor.notifyListeners.add(listener);
   if (timeout > 0 || nanos > 0) {
     listener.timerId =
         Platform.schedule(
             listener, timeout >= Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) timeout);
   }
   monitorExit(this, monitor.count);
 }
Пример #5
0
 @Override
 public void run() {
   if (performed) {
     return;
   }
   performed = true;
   if (timerId >= 0) {
     Platform.killSchedule(timerId);
     timerId = -1;
   }
   TThread.setCurrentThread(currentThread);
   monitorEnterWait(obj, lockCount, callback);
 }
Пример #6
0
 @Sync
 @Rename("notifyAll")
 public final void notifyAll0() {
   if (!holdsLock(this)) {
     throw new TIllegalMonitorStateException();
   }
   PlatformQueue<NotifyListener> listeners = monitor.notifyListeners;
   while (!listeners.isEmpty()) {
     NotifyListener listener = listeners.remove();
     if (!listener.expired()) {
       Platform.postpone(listener);
     }
   }
 }
Пример #7
0
 public Monitor() {
   this.owner = TThread.currentThread();
   enteringThreads = Platform.createQueue();
   notifyListeners = Platform.createQueue();
 }
Пример #8
0
 int identity() {
   return Platform.getPlatformObject(this).getId();
 }
Пример #9
0
 @Rename("getClass")
 public final TClass<?> getClass0() {
   return TClass.getClass(Platform.getPlatformObject(this).getPlatformClass());
 }
Пример #10
0
 @Rename("<init>")
 private void init() {
   Platform.getPlatformObject(this).setId(Platform.nextObjectId());
 }