we're okay to sync on the scheduling of the complete
433620
@Override
    public synchronized void complete() {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINEST)) {
            logger.entering(CLASS_NAME, "complete",this);
        }

        if (!lockHeldByDifferentThread())
        {
            //We can't call this or WebContainer won't know to run the complete runnable which kicks off the async listeners
            //        WebContainerRequestState.getInstance(true).setAsyncMode(false);

            if (!completePending){
                //Move this inside of if block because it complete is called
                //after a previous complete, you can get a NPE because the
                //request may have already been cleaned up. If complete is not
                //pending, then it shouldn't have been cleaned up.
                
                if (com.ibm.ws.webcontainer.osgi.WebContainer.getServletContainerSpecLevel() > 31) {
                    //setAsyncStarted(false) upon exit service()
                    WebContainerRequestState reqState = WebContainerRequestState.getInstance(true);
                    reqState.setAttribute("webcontainer.resetAsyncStartedOnExit", "true"); 
                }
                else {
                    iExtendedRequest.setAsyncStarted(false);
                }

                createNewAsyncServletReeentrantLock();

                cancelAsyncTimer();

                completeRunnable = new CompleteRunnable(iExtendedRequest,this);
                completePending = true;
                if (!dispatching){
                    executeNextRunnable();
                }

            }
        } else {
            if (WCCustomProperties.THROW_EXCEPTION_WHEN_UNABLE_TO_COMPLETE_OR_DISPATCH) {
                throw new IllegalStateException(nls.getString("AsyncContext.lock.already.held", "Unable to obtain the lock.  Error processing has already been invoked by another thread."));
            }
        }

        dispatchURI = null;

        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINEST)) {
            logger.exiting(CLASS_NAME, "complete",this);
        }

    }
30686
def _sync(pack):
    """"""
    task_queue = Queue()
    result_queue = Queue()
    task = SignedPackage.loads(pack)
    task_queue.put(task)
    task_queue.put('STOP')
    worker(task_queue, result_queue, Value('f', -1))
    result_queue.put('STOP')
    monitor(result_queue)
    task_queue.close()
    task_queue.join_thread()
    result_queue.close()
    result_queue.join_thread()
    return task['id']
52257
final void rescheduleIfNeeded() {
		if (executeEvery > 0 && !TaskScheduler.stopping) {
			synchronized (this) {
				status = Task.STATUS_NOT_STARTED;
				executeIn(executeEvery);
			}
			TaskScheduler.schedule(this);
		} else if (nextExecution > 0 && !TaskScheduler.stopping) {
			synchronized (this) {
				this.status = Task.STATUS_NOT_STARTED;
			}
			TaskScheduler.schedule(this);
		}
	}
1010365
function done() {
        var index = queue.length;

        while (index--) {
            patch(queue[index], one(queue[index]));
        }
    }
1264593
def sync(
    ctx,
    state,
    bare=False,
    user=False,
    unused=False,
    **kwargs
):
    """"""
    from ..core import do_sync

    retcode = do_sync(
        ctx=ctx,
        dev=state.installstate.dev,
        three=state.three,
        python=state.python,
        bare=bare,
        dont_upgrade=(not state.installstate.keep_outdated),
        user=user,
        clear=state.clear,
        unused=unused,
        sequential=state.installstate.sequential,
        pypi_mirror=state.pypi_mirror,
    )
    if retcode:
        ctx.abort()
963184
def _endSchedulesNode(self, name, content):
        """"""

        if name == 'schedule':
            if not self._error:
                self._importer.new_schedule(self._programId, self._stationId,
                                           self._time, self._duration,
                                           self._new, self._stereo,
                                           self._subtitled, self._hdtv,
                                           self._closeCaptioned, self._ei,
                                           self._tvRating, self._dolby,
                                           self._partNumber, self._partTotal)
1159070
void replicationComplete() {
        reloadTasksFromModel();
        Toast.makeText(getApplicationContext(),
                R.string.replication_completed,
                Toast.LENGTH_LONG).show();
        dismissDialog(DIALOG_PROGRESS);
    }
141481
def set_run_completed(self, boolean, start_datetime, end_datetime):
        """"""
        self._run_completed = boolean

        if (start_datetime, end_datetime) != (None, None):
            # start_datetime: Sat Feb 28 23:54:27 2015
            # end_datetime: Sat Feb 28 23:54:30 2015
            try:
                fmt = "%a %b %d %H:%M:%S %Y"
                self.start_datetime = datetime.datetime.strptime(start_datetime, fmt)
                self.end_datetime = datetime.datetime.strptime(end_datetime, fmt)
            except Exception as exc:
                # Maybe LOCALE != en_US
                logger.warning(str(exc))
41959
def complete(self):
        
        return self.valid and (self.access_token or self.refresh_token or self.type == 2)
619697
def schedule_saved(sender, instance, **kwargs):
    
    from contentstore.tasks import sync_schedule

    sync_schedule.delay(str(instance.id))
1186538
def sync_in(self, force=False):
        """"""
        self.log('---- Sync In ----')

        self.dstate = self.STATES.BUILDING

        for path_name in self.source_fs.listdir():

            f = self.build_source_files.instance_from_name(path_name)

            if not f:
                self.warn('Ignoring unknown file: {}'.format(path_name))
                continue

            if f and f.exists and (f.fs_is_newer or force):
                self.log('Sync: {}'.format(f.record.path))
                f.fs_to_record()
                f.record_to_objects()

        self.commit()

        self.library.search.index_bundle(self, force=True)
356757
def sync(self):
        
        phase = _get_phase(self._formula_instance)
        self.logger.info("%s %s..." % (phase.verb.capitalize(), self.feature_name))
        message = "...finished %s %s." % (phase.verb, self.feature_name)
        result = getattr(self, phase.name)()
        if result or phase in (PHASE.INSTALL, PHASE.REMOVE):
            self.logger.info(message)
        else:
            self.logger.debug(message)
        return result
92290
@SuppressWarnings("unused")
	@Scheduled(fixedDelay = DateUtils.MILLIS_PER_MINUTE)
	public void syncSubscriptions() {
		if (!mySyncSubscriptionsSemaphore.tryAcquire()) {
			return;
		}
		try {
			doSyncSubscriptionsWithRetry();
		} finally {
			mySyncSubscriptionsSemaphore.release();
		}
	}
573729
@Override
    public void run() {
        Date actualExecutionTime = new Date();
        super.run();
        Date completionTime = new Date();
        synchronized (this.triggerContextMonitor) {
            this.triggerContext.update(this.scheduledExecutionTime, actualExecutionTime, completionTime);
            if (!this.currentFuture.isCancelled()) {
                schedule();
            }
        }
    }
1200830
public void sync() {
        if (nextTick < 0) {
            throw new IllegalStateException("Timer was not started");
        }
        if (tps <= 0) {
            return;
        }
        try {
            // Sleep until the average sleep time is greater than the time remaining until next tick
            for (long time1 = getTime(), time2; nextTick - time1 > sleepDurations.average(); time1 = time2) {
                Thread.sleep(1);
                // Update average sleep time
                sleepDurations.add((time2 = getTime()) - time1);
            }
            // Slowly dampen sleep average if too high to avoid yielding too much
            sleepDurations.dampen();
            // Yield until the average yield time is greater than the time remaining until next tick
            for (long time1 = getTime(), time2; nextTick - time1 > yieldDurations.average(); time1 = time2) {
                Thread.yield();
                // Update average yield time
                yieldDurations.add((time2 = getTime()) - time1);
            }
        } catch (InterruptedException ignored) {
        }
        // Schedule next frame, drop frames if it's too late for next frame
        nextTick = Math.max(nextTick + 1000000000 / tps, getTime());
    }
965666
function(status, xhr, settings) {
		settings.complete.call(settings.context, xhr, status);
	}
1079256
private void reconcile() {

    // If nonContiguousMsgIds is empty then nothing to reconcile.
    if (nonContiguousMsgIds.isEmpty()) {
      return;
    }

    // This happens when a passive is started after Active has moved on and
    // passive starts to see msgIDs starting from a number > 0.
    // Once the sync is completed, fast forward highestContiguousMsgId.
    // Post sync completion assuming platform will send all msgIds beyond highestContiguousMsgId.
    if (highestContiguousMsgId == -1L && isSyncCompleted) {
      Long min = nonContiguousMsgIds.last();
      LOGGER.info("Setting highestContiguousMsgId to {} from -1", min);
      highestContiguousMsgId = min;
      nonContiguousMsgIds.removeIf(msgId -> msgId <= min);
    }

    for (long msgId : nonContiguousMsgIds) {
      if (msgId <= highestContiguousMsgId) {
        nonContiguousMsgIds.remove(msgId);
      } else if (msgId > highestContiguousMsgId + 1) {
        break;
      } else {
        // the order is important..
        highestContiguousMsgId = msgId;
        nonContiguousMsgIds.remove(msgId);
      }
    }

  }