Hold syncing any state until the outermost context manager exits
437398
def hold_sync(self):
        """"""
        if self._holding_sync is True:
            yield
        else:
            try:
                self._holding_sync = True
                yield
            finally:
                self._holding_sync = False
                self.send_state(self._states_to_send)
                self._states_to_send.clear()
528317
function(syncIt) {
	/* global setInterval */
	this._syncIt = syncIt;
	this._instructions = [];
	this._current = null;
	setInterval(function() {
		var args, c;
		if ((this._current === null) && this._instructions.length) {
			this._current = this._instructions.shift();
			args = Array.prototype.slice.call(this._current.a);
			args.push(function(e) {
				if (e !== SyncItConstant.Error.UNABLE_TO_PROCESS_BECAUSE_LOCKED) {
					c = this._current.c;
					this._current = null;
					c.apply(
						this._syncIt,
						arguments
					);
				}
			}.bind(this));
			this._current.f.apply(this._syncIt, args);
		}
	}.bind(this), 50);
}
1255424
private void safeCustomDelay(PollingStrategyContext pollingStrategyContext) {
        try {
            pollingStrategy.getDelayStrategy().delayBeforeNextRetry(pollingStrategyContext);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(e);
        }
    }
1128649
public static void onSaveInstanceState(Object context, Bundle outState) {

		if(ProfileService.getInstance(context).isActive(context, Profile.STATE) && outState != null) {
			
			long millis = System.currentTimeMillis();
		
			if(ContextUtils.isFragment(context))
				ContextUtils.asFragment(context).setRetainInstance(true);
			
			else if(ContextUtils.isSupportFragment(context)) 
				ContextUtils.asSupportFragment(context).setRetainInstance(true);
			
			StateService.newInstance(ContextUtils.discover(context)).save(context, outState);
			
			millis = System.currentTimeMillis() - millis;
				
			Log.i("INSTRUMENTATION:IckleStateProfile#onSaveInstanceState", 
				  StateUtils.class.getClass().getSimpleName() + ": " + millis + "ms");
		}
	}
1316386
function(state, transitionContext)
  {
    // this check is necessary to make sure we don't re-enter a transient state
    // like Renewing when we're already in it
    if (currentState !== state)
    {
      // if we have a current state, exit it; the null check is necessary
      // because the currentState is undefined at bootstrap time when we
      // transition to the first state
      if (currentState)
      {
        currentState.exit();
      }

      // update the current state
      currentState = state;

      // enter the new state
      currentState.enter(transitionContext);
    }
  }
1107827
def _synchronized(meth):
    """"""

    @functools.wraps(meth)
    def wrapper(self, *args, **kwargs):
        with self._lock:
            return meth(self, *args, **kwargs)

    return wrapper
254928
void waitForSyncEnd(String peerId)
      throws TimeoutException, IOException, InterruptedException {
    MessageTuple tuple = filter.getExpectedMessage(MessageType.SYNC_END,
                                                   peerId,
                                                   getSyncTimeoutMs());
    ClusterConfiguration cnf
      = ClusterConfiguration.fromProto(tuple.getMessage().getConfig(),
                                       this.serverId);
    LOG.debug("Got SYNC_END {} from {}", cnf, peerId);
    this.persistence.setLastSeenConfig(cnf);
    if (persistence.isInStateTransfer()) {
      persistence.endStateTransfer();
    }
    // If the synchronization is performed by truncation, then it's possible
    // the content of cluster_config has been truncated in log, then we'll
    // delete these invalid cluster_config files.
    persistence.cleanupClusterConfigFiles();
  }
74748
def preserve_batch_state():
    
    with LOCK:
        old = ROOT.gROOT.IsBatch()
        try:
            yield
        finally:
            ROOT.gROOT.SetBatch(old)
169100
def _wait_while_in_pause_or_in_step_mode(self):
        
        while (self._status.execution_mode is StateMachineExecutionStatus.PAUSED) \
                or (self._status.execution_mode is StateMachineExecutionStatus.STEP_MODE):
            try:
                self._status.execution_condition_variable.acquire()
                self.synchronization_counter += 1
                logger.verbose("Increase synchronization_counter: " + str(self.synchronization_counter))
                self._status.execution_condition_variable.wait()
            finally:
                self._status.execution_condition_variable.release()
938530
function pushLoadingState(xhrEvent, stateName, modelOrCollection, context, force) {
        var currentLoads = getState(stateName, context),
            currentlyLoading = currentLoads && currentLoads.length;
        if (!currentLoads) {
            currentLoads = [];
        }
        if (_.isArray(currentLoads)) {
            if (_.indexOf(currentLoads, xhrEvent) >= 0) {
                if (!force) {
                    return;
                }
                
            } else {
                currentLoads.push(xhrEvent);
            }
            
            if (!currentlyLoading) {
                var toSet = {};
                toSet[stateName] = currentLoads;
                setState(toSet, context);
            }

            xhrEvent.on('complete', function() {
                popLoadingState(xhrEvent, stateName, modelOrCollection, context);
            });
        }
    }
864717
def syncView(self):
        
        if not self.updatesEnabled():
            return
        
        for item in self.topLevelItems():
            try:
                item.syncView(recursive=True)
            except AttributeError:
                continue
690643
protected void synchronizeOutlinePage(INode element) {
		// TODO: don't search for mutexes
		if (element instanceof AMutexSyncDefinition)
			return;
		if (element instanceof ABlockSimpleBlockStm)
			return;

		try {
			synchronizeOutlinePage(element, false);// true
		} catch (Exception e) {

		}
	}
893102
def exit_sync(self):
        ''' 
        '''
        if self._scan_threads and self.current_module_handle not in [t.name for t in self._scan_threads]:
            raise RuntimeError('Thread name "%s" is not valid.')
        if self._scan_threads and self.current_module_handle not in self._curr_sync_threads:
            raise RuntimeError('Thread "%s" is not reading FIFO.')
        with self._sync_lock:
            self._curr_sync_threads.remove(self.current_module_handle)
        self._exit_sync_event.clear()
        while not self._exit_sync_event.wait(0.01):
            if self.abort_run.is_set():
                break
            with self._sync_lock:
                if len(set(self._curr_sync_threads) & set([t.name for t in self._scan_threads if t.is_alive()])) == 0 or not self._scan_threads:
                    self._exit_sync_event.set()
306177
private void updateState(final TaskStatus.State state) {
    statusUpdater.setState(state);
    // Commit and push a new status
    try {
      statusUpdater.update();
    } catch (InterruptedException e) {
      // TODO: propagate interrupt instead?
      Thread.currentThread().interrupt();
    }
  }
365426
def __sync(self):
    """"""
    pad_length = _BLOCK_SIZE - self.__reader.tell() % _BLOCK_SIZE
    if pad_length and pad_length != _BLOCK_SIZE:
      data = self.__reader.read(pad_length)
      if len(data) != pad_length:
        raise EOFError('Read %d bytes instead of %d' %
                       (len(data), pad_length))
242755
public void deactivate(ComponentContext context) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(this, tc, "Deactivating");
        }
        if (null != this.future) {
            synchronized (this.timerLock) {
                if (null != this.future) {
                    this.future.cancel(true);
                    this.future = null;
                }
            } // end-sync
        }
        // TODO purge the groupings/sessions maps, or dump to disk once
        // persistence is added
    }
487898
def set_until(self, frame, lineno=None):
        """"""
        self.state = Until(frame, frame.f_lineno)