restores invariants of the various states (e.g. spinningCount, descheduled collection and thread park status)
8219
boolean assign(Work work, boolean self)
    {
        Work state = get();
        while (state.canAssign(self))
        {
            if (!compareAndSet(state, work))
            {
                state = get();
                continue;
            }
            // if we were spinning, exit the state (decrement the count); this is valid even if we are already spinning,
            // as the assigning thread will have incremented the spinningCount
            if (state.isSpinning())
                stopSpinning();

            // if we're being descheduled, place ourselves in the descheduled collection
            if (work.isStop())
                pool.descheduled.put(workerId, this);

            // if we're currently stopped, and the new state is not a stop signal
            // (which we can immediately convert to stopped), unpark the worker
            if (state.isStopped() && (!work.isStop() || !stop()))
                LockSupport.unpark(thread);
            return true;
        }
        return false;
    }
1252444
private void cleanupCachedState() {
    int total = 0;
    int expired = 0;
    Iterator<Map.Entry<Id, Object>> it = state.entrySet().iterator();
    while (it.hasNext()) {
      ++total;
      Map.Entry<Id, Object> entry = it.next();
      Object obj = entry.getValue();
      if (obj instanceof Meter && ((Meter) obj).hasExpired()) {
        ++expired;
        it.remove();
      }
    }
    logger.debug("removed {} expired entries from cache out of {} total", expired, total);
  }
251026
def clean_deleted_sessions(cls):
        """"""
        for federate_slo in cls.objects.all():
            if not SessionStore(session_key=federate_slo.session_key).get('authenticated'):
                federate_slo.delete()
932247
private void cleanupViewStates() {
        completeRequestSpan(currentRequest());
        finishedDecoding();
        viewInfoObservable = null;
        viewRowObservable = null;
        viewErrorObservable = null;
        viewParsingState = QUERY_STATE_INITIAL;
    }
36666
def restore(self, hidden_state):
        
        for callback in self.callbacks:
            callback.load_state_dict(self, hidden_state)

        if 'optimizer' in hidden_state:
            self.optimizer_initial_state = hidden_state['optimizer']
521456
def restore_state(self):
        
        current_mask = get_IO_reg(ControlCluster.bus,
                                 self.IOexpander, 
                                 self.bank)
        if current_mask & (1 << ControlCluster.pump_pin):
            self.manage_pump("on")
        if current_mask & (1 << self.fan):
            self.manage_fan("on")
        if current_mask & (1 << self.light):
            self.manage_fan("on")
653468
@Override
    public void rnnSetPreviousState(Map<String, INDArray> stateMap) {
        this.stateMap.clear();
        this.stateMap.putAll(stateMap);
    }
202912
@Override
    public void onRestoreInstanceState(Parcelable state) {

        if (state instanceof Bundle) {
            Bundle bundle = (Bundle) state;
            //load everything
            PinViewSettings pinViewSettings = bundle.getParcelable("stateSettings");
            if (pinViewSettings != null) {
                setSettings(pinViewSettings);
            }
            String pinResults = bundle.getString("statePinResults");
            setPinResults(pinResults);
            state = bundle.getParcelable("instanceState");
        }
        super.onRestoreInstanceState(state);
    }
1120717
private void cleanRestoredHandles() throws Exception {
		synchronized (pendingCheckpoints) {

			Iterator<PendingCheckpoint> pendingCheckpointIt = pendingCheckpoints.iterator();
			while (pendingCheckpointIt.hasNext()) {
				PendingCheckpoint pendingCheckpoint = pendingCheckpointIt.next();

				if (committer.isCheckpointCommitted(pendingCheckpoint.subtaskId, pendingCheckpoint.checkpointId)) {
					pendingCheckpoint.stateHandle.discardState();
					pendingCheckpointIt.remove();
				}
			}
		}
	}
837549
def restore_geometry_state(self, gs):
        
        if not gs:
            return
        if gs.get('geometry', None):
            self.restoreGeometry((gs['geometry']))
        if gs.get('state', None):
            self.restoreState((gs['state']))
646908
def cleanup_relations(self):
        """"""
        collections = self.collections
        for relation in [x for col in collections.values()
                         for x in col.model.relations.values()]:
            db.session.query(relation)\
                       .filter(~relation.listing.any())\
                       .delete(synchronize_session=False)
        db.session.commit()
282932
def reset_internal_states(self, record=None):
        
        self._record = None
        self._count = 0
        self._record = record
815611
def _restore_counts_maps(self):
        

        for c in self.components:
            c.restore_counts_maps()

        if hasattr(self.like.components[0].logLike, 'setCountsMap'):
            self._init_roi_model()
        else:
            self.write_xml('tmp')
            self._like = SummedLikelihood()
            for i, c in enumerate(self._components):
                c._create_binned_analysis()
                self._like.addComponent(c.like)
            self._init_roi_model()
            self.load_xml('tmp')
225097
protected function restoreErroneousMappers() {
        $this->erroneousMappers->rewind();
        while ($this->erroneousMappers->valid()) {
            $this->erroneousMappers->current()->save();
            $this->erroneousMappers->next();
        }
    }
1138196
public void restoreState() {
        content.append("Q").append_i(separator);
        int idx = stateList.size() - 1;
        if (idx < 0)
            throw new IllegalPdfSyntaxException("Unbalanced save/restore state operators.");
        state = (GraphicState)stateList.get(idx);
        stateList.remove(idx);
    }
1168421
def restore_gc_state():
    
    old_isenabled = gc.isenabled()
    old_flags = gc.get_debug()
    try:
        yield
    finally:
        gc.set_debug(old_flags)
        (gc.enable if old_isenabled else gc.disable)()
665309
synchronized void resumeStatsCollection(Timestamp now) {
    for (Entry<String, Collection<MutableViewData>> entry : mutableMap.asMap().entrySet()) {
      for (MutableViewData mutableViewData : entry.getValue()) {
        mutableViewData.resumeStatsCollection(now);
      }
    }
  }