@Override
  public <T> Task<T> synchronize(Task<T> task, long deadline) {
    return PlanLocal.get(getPlanLocalKey(), LockInternal.class)
        .flatMap(lockInternal -> {
          if (lockInternal != null) {
            // we already acquire the lock, add count only.
            lockInternal._lockCount++;
            return Task.value(lockInternal._lockNode);
          } else {
            // try acquire.
            return acquire(deadline);
          }
        })
        /* run the given task with toTry() */
        .flatMap(unused -> task).toTry()
        /* release the lock and unwind the result */
        .flatMap(result -> release().andThen(unwind(result)));
  }
@Override
  public <T> Task<T> synchronize(Task<T> task, long deadline) {
    return PlanLocal.get(getPlanLocalKey(), LockInternal.class)
        .flatMap(lockInternal -> {
          if (lockInternal != null) {
            
            lockInternal._lockCount++;
            return Task.value(lockInternal._lockNode);
          } else {
            
            return acquire(deadline);
          }
        })
        
        .flatMap(unused -> task).toTry()
        
        .flatMap(result -> release().andThen(unwind(result)));
  }
@ Override public < T > Task < T > synchronize ( Task < T > task , long deadline ) { return PlanLocal . get ( getPlanLocalKey ( ) , LockInternal . class ) . flatMap ( lockInternal -> { if ( lockInternal != null ) { // we already acquire the lock, add count only. lockInternal . _lockCount ++ ; return Task . value ( lockInternal . _lockNode ) ; } else { // try acquire. return acquire ( deadline ) ; } } ) /* run the given task with toTry() */ . flatMap ( unused -> task ) . toTry ( ) /* release the lock and unwind the result */ . flatMap ( result -> release ( ) . andThen ( unwind ( result ) ) ) ; }
{@inheritDoc}
{