TODO: Do we need to synchronize this? (or use Concurrent)
771581
public void aggregateValue(TridentTuple tuple) {
        K key = mapper.getKey(tuple);
        V value = mapper.getValue(tuple);
        V currentValue = aggregateValues.get(key);
        V newValue;
        if (currentValue == null) {
            newValue = aggregator.init(tuple);
        } else {
            newValue = aggregator.combine(currentValue, value);
        }
        LOG.debug("Updating state [{}] ==> [{}]", new Object[]{key, newValue});
        aggregateValues.put(key, newValue);
    }
825644
@Override
    public void sync( NativeObject jsRWB, Object data ) {
        synchronizationPoint(jsRWB, null, data);
    }
12094
function (item, req, eachReq, res, next) {
          eachReq.item = item;
          eachReq[indexKey] = index;
          index++;
          next();
        }
1298718
function (objs, cb) {

      var results = []
        ,   done = false
        ,   self = this

      var updateProgress = function(obj) {
        results.push(obj)
        done = results.length === objs.length
      }

      var checkProgress = setInterval(function() {
        if (done) {
          if (cb) self.lambda(cb).call(self, results)
          clearInterval(checkProgress)
        }
      }, 200)

      for (var i = 0, l = objs.length; i < l; i++)
        this.save(objs[i], updateProgress)

      return this
    }
711584
function(callbacks, args) {
            if (!callbacks.length) {
                return typeof done === 'function' ? done() : true;
            }

            var callback = callbacks.shift();
            callback.apply(context, args);

            // Is the callback synchronous ?
            if (callback.length === nbArguments) {
                iterator(callbacks, args, done);
            }
        }
238876
@Override
    public final void complete(Object res, Object error) {
        this.result = res;
        Object prevErr = this.error;
        this.error = error;
        while( !lock.compareAndSet(false,true) ) {}
        try {
            if (hadResult) {
                if ( prevErr instanceof Timeout ) {
                    this.error = prevErr;
                    lock.set(false);
                    return;
                }
                lock.set(false);
                throw new RuntimeException("Double result received on future prevErr:" + prevErr +" (res,err) "+res+","+error );
            }
            hadResult = true;
            if (resultReceiver != null) {
                if (hasFired) {
                    lock.set(false);
                    throw new RuntimeException("Double fire on callback");
                }
                hasFired = true;
                lock.set(false);
                resultReceiver.complete(result, error);
                resultReceiver = null;
                while (!lock.compareAndSet(false, true)) {
                }
                if (nextFuture != null) {
                    lock.set(false);
                    nextFuture.complete(result, error);
                }
                return;
            }
        } finally {
            lock.set(false);
        }
    }
1314039
function (set, receive) {
	var values = setValues.call(set);
	var next;
	do {
		next = values.next();
	} while (!next.done && receive(next.value));
}
370263
public void synchronize(List<? extends E> list) {
		assert SwingUtilities.isEventDispatchThread() : ApplicationResources.accessor.getMessage("assert.notRunningInSwingEventThread");

		// Make sure the first element exists and matches
		int modelOffset;
		if(constantFirstRow!=null) {
			modelOffset = 1;
			if(getSize()==0) addElement(constantFirstRow);
			else if(!getElementAt(0).equals(constantFirstRow)) {
				insertElementAt(constantFirstRow, 0);
			}
		} else modelOffset = 0;

		// Synchronize the dynamic part of the list
		int size = list.size();
		for(int index=0; index<size; index++) {
			E obj = list.get(index);
			if(index>=(getSize()-modelOffset)) addElement(obj);
			else if(!obj.equals(getElementAt(index+modelOffset))) {
				// Objects don't match
				// If this object is found further down the list, then delete up to that object
				int foundIndex = -1;
				for(int searchIndex = index+1; searchIndex<(getSize()-modelOffset); searchIndex++) {
					if(obj.equals(getElementAt(searchIndex+modelOffset))) {
						foundIndex = searchIndex;
						break;
					}
				}
				if(foundIndex!=-1) {
					// No removeRange
					// removeRange(index+modelOffset, foundIndex-1+modelOffset);
					for(
						int removeIndex = foundIndex-1+modelOffset, end = index+modelOffset;
						removeIndex>=end;
						removeIndex--
					) removeElementAt(removeIndex);
				} else {
					// Otherwise, insert in the current index
					insertElementAt(obj, index+modelOffset);
				}
			}
		}
		// Remove any extra
		while((getSize()-modelOffset) > size) removeElementAt(getSize()-1);
	}
926723
public function sync()
    {
        $this->connection()->transaction(function () {
            foreach ($this->editable() as $field) {
                // get original HTML input
                $field = $field->getInput();

                $name = $field->getName();

                if ($this->isKey($field) || $this->isTranslatable($field) || $this->isMediaFile($field)) {
                    continue;
                }

                $this->collectRelations($field, $name);

                $value = $this->isFile($field) ? $this->request->file($name) : $this->request->get($name);

                $value = $this->isBoolean($field) ? (bool) $value : $value;

                $value = $this->handleJsonType($name, $value);

                $this->data[$name] = $value;
            }

            $this->cleanData();

            $this->collectTranslatable();

            $this->appendTranslationsToRelations();

            Model::unguard();

            /*
            |-------------------------------------------------------
            | Save main data
            |-------------------------------------------------------
            */
            $this->save();

            /*
            |-------------------------------------------------------
            | Relationships
            |-------------------------------------------------------
            | Save related data, fetched by "relation" from related tables
            */
            $this->saveRelations();

            $this->saveMedia();

            Model::reguard();
        });

        return $this->repository;
    }
1096780
function(callback, thisp) {
		this._callback = callback ? callback : null;
		this._pointer = thisp ? thisp : null;
		if (this._now) {
			this.now();
		}
	}
208993
private void writeRead() {
		// Execute on background thread as we don't know how large this is
		new AsyncTask<Void, Void, Void>() {
			@Override
			protected Void doInBackground(Void... params) {
				// Get editor & basic variables
				SharedPreferences.Editor editor = mPrefs.edit();
				int size = readList.size();
				boolean value;

				editor.putInt("READ_ARRAY_SIZE", size);
				for(int i = 0, key; i < size; i++) {
					key = readList.keyAt(i);
					value = readList.get(key);

					editor.putInt("READ_ARRAY_KEY_" + i, key);
					editor.putBoolean("READ_ARRAY_VALUE_" + i, value);
				}
				editor.commit();

				return null;
			}
		}.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
	}
1147941
public synchronized boolean sync() {
		if (!validState) {
			throw new InvalidStateException();
		}
		try {
			fc.force(false);
			return true;
		} catch (Exception e) {
			log.error("Exception in sync()", e);
		}
		return false;
	}
975266
public void onStartObject() {
		this.currentObjectKey = this.currentLocalName;
		if (this.firstObjectKey == null && this.currentLocalName != null) {
			this.firstObjectKey = this.currentObjectKey;
		}

		if (this.currentObjectKey != null) {
			stackObjectKey.push(this.currentObjectKey);
		} else {
			if (!stackObjectKey.isEmpty()) {
				this.currentObjectKey = stackObjectKey.peek();
			} else {
				this.currentObjectKey = this.firstObjectKey;
			}
		}
	}
730848
public void execute() {
    Entry head;
    synchronized(this) {
      head = this.head;
      this.head = null;
    }
    while (head != null) {
      try {
        head.runnable.run();
      } catch (Throwable t) {
        platform.reportError("Failure executing runnable: " + head.runnable, t);
      }
      head = head.next;
    }
  }
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);
}
171720
public void run () {
  //wait for finished item
  //send finished item to encoder
  //loop to top
  boolean loop = true;
  boolean interrupted = false;
  try {
    while(loop) {
      try {
        if(nextTarget == null)
          nextTarget = orderedEncodeRequests.poll(500,TimeUnit.MILLISECONDS);
        if(nextTarget == null) {
          loop = false;
        }
        else if(nextTarget.frameNumber < 0) {
          loop = false;
          nextTarget = null;
          orderedEncodeRequests.clear();
        }
        else if(finishedRequestStore.remove(nextTarget)) {
          encoder.blockFinished(nextTarget);
          nextTarget = null;
          synchronized(outstandingCountLock) {
            outstandingCount--;
            outstandingCountLock.notifyAll();
          }
        }
        else {
          BlockEncodeRequest ber = finishedEncodeRequests.poll(500, TimeUnit.MILLISECONDS);
          if(ber == null) {//nothing to process yet, let this thread end.
            loop = false;
          }
          else if(nextTarget == ber) {
            encoder.blockFinished(ber);
            nextTarget = null;
            synchronized(outstandingCountLock) {
              outstandingCount--;
              outstandingCountLock.notifyAll();
            }
          }
          else {
            finishedRequestStore.add(ber);
          }
        }
        }catch(InterruptedException e) {
          interrupted = true;
        }
      }
    }finally {
      if(interrupted)
      Thread.currentThread().interrupt();
    }
    synchronized(this) {
      managerThread = null;
      restartManager();
    }
  }
1093185
function() {
      var authData = this.get('authData');
      if (!authData) {
        return;
      }

      var self = this;
      Parse._objectEach(this.get('authData'), function(value, key) {
        self._synchronizeAuthData(key);
      });
    }