s243a

MessageFilter.onMatched

Jun 20th, 2015
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1.  
  2. // line 405 of https://github.com/freenet/fred/blob/3fcc2d1b3a0d5ccbeb73928d6b267440e5b4c17b/src/freenet/io/comm/MessageFilter.java
  3. /**
  4.      * Notify waiters that we have been matched.
  5.      * Hopefully no locks will be held at this point by the caller.
  6.      */
  7.     public void onMatched(Executor executor) {
  8.         final Message msg;
  9.         final AsyncMessageFilterCallback cb;
  10.         ByteCounter ctr;
  11.         synchronized(this) {
  12.             msg = _message;
  13.             cb = _callback;
  14.             ctr = _ctr;
  15.             // Clear matched before calling callback in case we are re-added.
  16.             if(_callback != null)
  17.                 clearMatched();
  18.         }
  19.         if(cb != null) {
  20.             if(cb instanceof SlowAsyncMessageFilterCallback)
  21.                 executor.execute(new PrioRunnable() {
  22.  
  23.                     @Override
  24.                     public void run() {
  25.                         cb.onMatched(msg);
  26.                     }
  27.  
  28.                     @Override
  29.                     public int getPriority() {
  30.                         return ((SlowAsyncMessageFilterCallback)cb).getPriority();
  31.                     }
  32.                    
  33.                 }, "Slow callback for "+cb);
  34.             else
  35.                 cb.onMatched(msg);
  36.             if(ctr != null)
  37.                 ctr.receivedBytes(msg._receivedByteCount);
  38.         }
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment