/** * Adds a task to the frame task queue. * * @param task AFrameTask to be added. * @return boolean True on successful addition to queue. */ private boolean internalOfferTask(AFrameTask task) { synchronized (mFrameTaskQueue) { return mFrameTaskQueue.offer(task); } }
@Override protected void subAppend(LoggingEvent event) { synchronized (this.events) { while (this.events.size() >= this.logBufferSize) { this.events.poll(); } this.events.offer(event); } super.subAppend(event); }
private void increaseProgress(final FloatingActionButton fab, int i) { if (i <= mMaxProgress) { fab.setProgress(i, false); final int progress = ++i; mUiHandler.postDelayed(new Runnable() { @Override public void run() { increaseProgress(fab, progress); } }, 30); } else { mUiHandler.postDelayed(new Runnable() { @Override public void run() { fab.hideProgress(); } }, 200); mProgressTypes.offer(ProgressType.PROGRESS_NO_ANIMATION); } }
@Override protected XMLEvent internalNextEvent() throws XMLStreamException { //If there is an iterator to read from reset was called, use the iterator //until it runs out of events. if (this.bufferReader != null) { final XMLEvent event = this.bufferReader.next(); //If nothing left in the iterator, remove the reference and fall through to direct reading if (!this.bufferReader.hasNext()) { this.bufferReader = null; } return event; } //Get the next event from the underlying reader final XMLEvent event = this.getParent().nextEvent(); //if buffering add the event if (this.eventLimit != 0) { this.eventBuffer.offer(event); //If limited buffer size and buffer is too big trim the buffer. if (this.eventLimit > 0 && this.eventBuffer.size() > this.eventLimit) { this.eventBuffer.poll(); } } return event; }
@Override protected XMLEvent internalNextEvent() throws XMLStreamException { //If there is an iterator to read from reset was called, use the iterator //until it runs out of events. if (this.bufferReader != null) { final XMLEvent event = this.bufferReader.next(); //If nothing left in the iterator, remove the reference and fall through to direct reading if (!this.bufferReader.hasNext()) { this.bufferReader = null; } return event; } //Get the next event from the underlying reader final XMLEvent event = this.getParent().nextEvent(); //if buffering add the event if (this.eventLimit != 0) { this.eventBuffer.offer(event); //If limited buffer size and buffer is too big trim the buffer. if (this.eventLimit > 0 && this.eventBuffer.size() > this.eventLimit) { this.eventBuffer.poll(); } } return event; }
public void addWorkUnit(AuditWorkUnit vwu) { if ( vwu.containsWork() ) { final Object entityId = vwu.getEntityId(); if ( entityId == null ) { // Just adding the work unit - it's not associated with any persistent entity. workUnits.offer( vwu ); } else { final String entityName = vwu.getEntityName(); final Pair<String, Object> usedIdsKey = Pair.make( entityName, entityId ); if ( usedIds.containsKey( usedIdsKey ) ) { final AuditWorkUnit other = usedIds.get( usedIdsKey ); final AuditWorkUnit result = vwu.dispatch( other ); if ( result != other ) { removeWorkUnit( other ); if ( result != null ) { usedIds.put( usedIdsKey, result ); workUnits.offer( result ); } // else: a null result means that no work unit should be kept } // else: the result is the same as the work unit already added. No need to do anything. } else { usedIds.put( usedIdsKey, vwu ); workUnits.offer( vwu ); } } } }
fab.setShowProgressBackground(true); fab.setIndeterminate(true); mProgressTypes.offer(ProgressType.INDETERMINATE); break; case PROGRESS_POSITIVE: fab.setIndeterminate(false); fab.setProgress(70, true); mProgressTypes.offer(ProgressType.PROGRESS_POSITIVE); break; case PROGRESS_NEGATIVE: fab.setProgress(30, true); mProgressTypes.offer(ProgressType.PROGRESS_NEGATIVE); break; case HIDDEN: fab.hideProgress(); mProgressTypes.offer(ProgressType.HIDDEN); break; case PROGRESS_NO_ANIMATION: fab.setShowProgressBackground(false); fab.setIndeterminate(true); mProgressTypes.offer(ProgressType.PROGRESS_NO_BACKGROUND); break;
mProgressTypes = new LinkedList<>(); for (ProgressType type : ProgressType.values()) { mProgressTypes.offer(type);
GenericRecord newRecord = (GenericRecord) newValue; if (oldRecord.getSchema().getFullName().equals(newRecord.getSchema().getFullName())) { nextRecords.offer(new RecordTuple(oldRecord, newRecord)); } else { hasDifferences = true; GenericFixed newUuid = (GenericFixed) newItemRecord.get(UUID_FIELD); if (uuid.equals(newUuid)) { nextRecords.offer(new RecordTuple(oldItemRecord, newItemRecord)); isRecordExists = true; break;
/** * Use if it includes a link. * Does not escape '<' and '>' before queueing * * @return the message id */ public synchronized int addMessageNoEscape(String message) { _messages.offer(new Message(_count++, message)); while (_messages.size() > _maxSize) { _messages.poll(); } return _count; }
@AsyncThread private void runQueue() { ChainFuture cf; synchronized (chainTasks) { // remove from pending queue and add to running queue later cf = (ChainFuture) pendingQueue.poll(); if (cf == null) { if (counter.decrementAndGet() == 0) { chainTasks.remove(syncSignature); } return; } } synchronized (runningQueue) { cf.startExecutionTimeInMills = System.currentTimeMillis(); // add to running queue logger.debug(String.format("Start executing runningQueue: %s, task name: %s", syncSignature, cf.getTask().getName())); runningQueue.offer(cf); } cf.run(() -> { synchronized (runningQueue) { runningQueue.remove(cf); logger.debug(String.format("Finish executing runningQueue: %s, task name: %s", syncSignature, cf.getTask().getName())); } runQueue(); }); }
void addTask(ChainFuture task) { pendingQueue.offer(task); if (maxThreadNum == -1) { maxThreadNum = task.getSyncLevel(); } else if (maxThreadNum < task.getSyncLevel()) { logger.warn(String.format("task[name:%s] increases queue[name:%s]'s sync level from %s to %s", task.getTask().getName(), task.getSyncSignature(), maxThreadNum, task.getSyncLevel())); maxThreadNum = task.getSyncLevel(); } if (syncSignature == null) { syncSignature = task.getSyncSignature(); } }
/** * Adds a task to the frame task queue. * * @param task AFrameTask to be added. * @return boolean True on successful addition to queue. */ private boolean internalOfferTask(AFrameTask task) { synchronized (mFrameTaskQueue) { return mFrameTaskQueue.offer(task); } }
private T handleLeader() { T next = it.next(); buffer.offer(next); return next; }
public boolean offer(Env<AttrContext> e) { if (fileContents.offer(e)) { contents.add(e); return true; } return false; }
@Override public JsonVerifiable elementWithIndex(int index) { ArrayAssertion asserter = new ArrayAssertion(parsedJson, jsonPathBuffer, jsonAsserterConfiguration); asserter.jsonPathBuffer.offer("[" + index + "]"); return asserter; }
private void LogActivity(Activity activity) { synchronized (transcript) { if (activity.timestamp() == null) { activity.withTimestamp(DateTime.now(DateTimeZone.UTC)); } transcript.offer(activity); } }