Skip to content

Instantly share code, notes, and snippets.

View juanavelez's full-sized avatar

Juan Velez juanavelez

  • http://www.twilio.com
  • Seattle, WA, USA
View GitHub Profile
@juanavelez
juanavelez / Context.java
Created April 15, 2017 00:37
execute-blocking-code-multiple-queues
/**
* Similar to {@link #executeBlocking(Handler, Handler)} but when this method is called several times on the same
* context for the same {@code identifier}, executions associated to that value will be executed serially.
* However executions associated to different identifiers will be executed in parallel.
* @param identifier Object used to group and serialize executions
* @param blockingCodeHandler handler representing the blocking code to run
* @param resultHandler handler that will be called when the blocking code is complete
* @param <T> the type of the result
*/
<T> void executeBlocking(Object identifier, Handler<Future<T>> blockingCodeHandler, Handler<AsyncResult<T>> resultHandler);