/** * Receives message and batches as needed. */ @Override protected void onMessageOnProducerThread(T msg) { synchronized (_lock) { if (_pending == null) { _pending = new ArrayList<>(); _queue.schedule(_flushRunnable, _interval, _timeUnit); } _pending.add(msg); } }
/** * Receives message and batches as needed. */ @Override protected void onMessageOnProducerThread(T msg) { synchronized (_lock) { if (_pending == null) { _pending = new ArrayList<>(); _queue.schedule(_flushRunnable, _interval, _timeUnit); } _pending.add(msg); } }
/** * Message received and batched on producer thread. */ @Override protected void onMessageOnProducerThread(T msg) { synchronized (_batchLock) { K key = _keyResolver.convert(msg); if (_pending == null) { _pending = new HashMap<>(); _context.schedule(_flushRunner, _flushIntervalInMs, _timeUnit); } _pending.put(key, msg); } }
@Override protected void onMessageOnProducerThread(T msg) { synchronized (_lock) { if (!_flushPending) { _flushPending = true; if (_flushIntervalInMs < 1) { _context.execute(_flushRunnable); } else { _context.schedule(_flushRunnable, _flushIntervalInMs, _timeUnit); } } _pending = msg; } }
@Override protected void onMessageOnProducerThread(T msg) { synchronized (_lock) { if (!_flushPending) { _flushPending = true; if (_flushIntervalInMs < 1) { _context.execute(_flushRunnable); } else { _context.schedule(_flushRunnable, _flushIntervalInMs, _timeUnit); } } _pending = msg; } }
/** * Message received and batched on producer thread. */ @Override protected void onMessageOnProducerThread(T msg) { synchronized (_batchLock) { K key = _keyResolver.convert(msg); if (_pending == null) { _pending = new HashMap<>(); _context.schedule(_flushRunner, _flushIntervalInMs, _timeUnit); } _pending.put(key, msg); } }
public void send(RequestChannel<R, V> channel, R req, Fiber target) { // send may occur from a different thread than the receive thread. // Once the message is sent there is a race. The lock prevents the receiving thread from // attempting to dispose before the variables are properly set. synchronized (lock) { final Disposable requestDispose = channel.publish(target, req, this); if (timeout != null) { final Disposable timer = target.schedule(this, timeout.time, timeout.unit); this.d = new Disposable() { public void dispose() { requestDispose.dispose(); timer.dispose(); } }; } else { d = requestDispose; } } } }
public void send(RequestChannel<R, V> channel, R req, Fiber target) { // send may occur from a different thread than the receive thread. // Once the message is sent there is a race. The lock prevents the receiving thread from // attempting to dispose before the variables are properly set. synchronized (lock) { final Disposable requestDispose = channel.publish(target, req, this); if (timeout != null) { final Disposable timer = target.schedule(this, timeout.time, timeout.unit); this.d = new Disposable() { public void dispose() { requestDispose.dispose(); timer.dispose(); } }; } else { d = requestDispose; } } } }
/** * Receives message and batches as needed. */ @Override protected void onMessageOnProducerThread(T msg) { _lock.lock(); try { if (_pending.isEmpty()) { _queue.schedule(_flushRunnable, _interval, _timeUnit); } _pending.add(msg); } finally { _lock.unlock(); } }
/** * Receives message and batches as needed. */ @Override protected void onMessageOnProducerThread(T msg) { _lock.lock(); try { if (_pending.isEmpty()) { _queue.schedule(_flushRunnable, _interval, _timeUnit); } _pending.add(msg); } finally { _lock.unlock(); } }