コード例 #1
0
 @Override
 void request(AbstractRequestBodyPublisher publisher, long n) {
   if (BackpressureUtils.checkRequest(n, publisher.subscriber)) {
     BackpressureUtils.addAndGet(publisher.demand, n);
     if (publisher.changeState(this, DEMAND)) {
       publisher.checkOnDataAvailable();
     }
   }
 }
コード例 #2
0
 @Override
 void onDataAvailable(AbstractRequestBodyPublisher publisher) {
   if (publisher.changeState(this, READING)) {
     try {
       boolean demandAvailable = publisher.readAndPublish();
       if (demandAvailable) {
         publisher.changeState(READING, DEMAND);
         publisher.checkOnDataAvailable();
       } else {
         publisher.changeState(READING, NO_DEMAND);
       }
     } catch (IOException ex) {
       publisher.onError(ex);
     }
   }
 }