📄 abstractiosession.html
字号:
<a name="499" href="#499">499</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">void</strong> setScheduledWriteBytes(<strong class="jxr_keyword">long</strong> byteCount){<a name="500" href="#500">500</a> scheduledWriteBytes.set(byteCount);<a name="501" href="#501">501</a> }<a name="502" href="#502">502</a> <a name="503" href="#503">503</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">void</strong> setScheduledWriteMessages(<strong class="jxr_keyword">int</strong> messages) {<a name="504" href="#504">504</a> scheduledWriteMessages.set(messages);<a name="505" href="#505">505</a> }<a name="506" href="#506">506</a> <a name="507" href="#507">507</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> increaseReadBytes(<strong class="jxr_keyword">long</strong> increment, <strong class="jxr_keyword">long</strong> currentTime) {<a name="508" href="#508">508</a> <strong class="jxr_keyword">if</strong> (increment <= 0) {<a name="509" href="#509">509</a> <strong class="jxr_keyword">return</strong>;<a name="510" href="#510">510</a> }<a name="511" href="#511">511</a> <a name="512" href="#512">512</a> readBytes += increment;<a name="513" href="#513">513</a> lastReadTime = currentTime;<a name="514" href="#514">514</a> idleCountForBoth = 0;<a name="515" href="#515">515</a> idleCountForRead = 0;<a name="516" href="#516">516</a> <a name="517" href="#517">517</a> <strong class="jxr_keyword">if</strong> (getService() instanceof AbstractIoService) {<a name="518" href="#518">518</a> ((<a href="../../../../org/apache/mina/common/AbstractIoService.html">AbstractIoService</a>) getService()).increaseReadBytes(increment, currentTime);<a name="519" href="#519">519</a> }<a name="520" href="#520">520</a> }<a name="521" href="#521">521</a> <a name="522" href="#522">522</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> increaseReadMessages(<strong class="jxr_keyword">long</strong> currentTime) {<a name="523" href="#523">523</a> readMessages++;<a name="524" href="#524">524</a> lastReadTime = currentTime;<a name="525" href="#525">525</a> idleCountForBoth = 0;<a name="526" href="#526">526</a> idleCountForRead = 0;<a name="527" href="#527">527</a> <a name="528" href="#528">528</a> <strong class="jxr_keyword">if</strong> (getService() instanceof AbstractIoService) {<a name="529" href="#529">529</a> ((<a href="../../../../org/apache/mina/common/AbstractIoService.html">AbstractIoService</a>) getService()).increaseReadMessages(currentTime);<a name="530" href="#530">530</a> }<a name="531" href="#531">531</a> }<a name="532" href="#532">532</a> <a name="533" href="#533">533</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> increaseWrittenBytesAndMessages(<a name="534" href="#534">534</a> <a href="../../../../org/apache/mina/common/WriteRequest.html">WriteRequest</a> request, <strong class="jxr_keyword">long</strong> currentTime) {<a name="535" href="#535">535</a> <a name="536" href="#536">536</a> Object message = request.getMessage();<a name="537" href="#537">537</a> <strong class="jxr_keyword">if</strong> (message instanceof IoBuffer) {<a name="538" href="#538">538</a> <a href="../../../../org/apache/mina/common/IoBuffer.html">IoBuffer</a> b = (IoBuffer) message;<a name="539" href="#539">539</a> <strong class="jxr_keyword">if</strong> (b.hasRemaining()) {<a name="540" href="#540">540</a> increaseWrittenBytes(((IoBuffer) message).remaining(), currentTime);<a name="541" href="#541">541</a> } <strong class="jxr_keyword">else</strong> {<a name="542" href="#542">542</a> increaseWrittenMessages(currentTime);<a name="543" href="#543">543</a> }<a name="544" href="#544">544</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (message instanceof FileRegion) {<a name="545" href="#545">545</a> <a href="../../../../org/apache/mina/common/FileRegion.html">FileRegion</a> region = (FileRegion) message;<a name="546" href="#546">546</a> <strong class="jxr_keyword">if</strong> (region.getCount() == 0) {<a name="547" href="#547">547</a> increaseWrittenBytes(region.getWrittenBytes(), currentTime);<a name="548" href="#548">548</a> increaseWrittenMessages(currentTime);<a name="549" href="#549">549</a> }<a name="550" href="#550">550</a> } <strong class="jxr_keyword">else</strong> {<a name="551" href="#551">551</a> increaseWrittenMessages(currentTime);<a name="552" href="#552">552</a> }<a name="553" href="#553">553</a> }<a name="554" href="#554">554</a> <a name="555" href="#555">555</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> increaseWrittenBytes(<strong class="jxr_keyword">long</strong> increment, <strong class="jxr_keyword">long</strong> currentTime) {<a name="556" href="#556">556</a> <strong class="jxr_keyword">if</strong> (increment <= 0) {<a name="557" href="#557">557</a> <strong class="jxr_keyword">return</strong>;<a name="558" href="#558">558</a> }<a name="559" href="#559">559</a> <a name="560" href="#560">560</a> writtenBytes += increment;<a name="561" href="#561">561</a> lastWriteTime = currentTime;<a name="562" href="#562">562</a> idleCountForBoth = 0;<a name="563" href="#563">563</a> idleCountForWrite = 0;<a name="564" href="#564">564</a> <a name="565" href="#565">565</a> <strong class="jxr_keyword">if</strong> (getService() instanceof AbstractIoService) {<a name="566" href="#566">566</a> ((<a href="../../../../org/apache/mina/common/AbstractIoService.html">AbstractIoService</a>) getService()).increaseWrittenBytes(increment, currentTime);<a name="567" href="#567">567</a> }<a name="568" href="#568">568</a> <a name="569" href="#569">569</a> increaseScheduledWriteBytes(-increment);<a name="570" href="#570">570</a> }<a name="571" href="#571">571</a> <a name="572" href="#572">572</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> increaseWrittenMessages(<strong class="jxr_keyword">long</strong> currentTime) {<a name="573" href="#573">573</a> writtenMessages++;<a name="574" href="#574">574</a> lastWriteTime = currentTime;<a name="575" href="#575">575</a> <strong class="jxr_keyword">if</strong> (getService() instanceof AbstractIoService) {<a name="576" href="#576">576</a> ((<a href="../../../../org/apache/mina/common/AbstractIoService.html">AbstractIoService</a>) getService()).increaseWrittenMessages(currentTime);<a name="577" href="#577">577</a> }<a name="578" href="#578">578</a> <a name="579" href="#579">579</a> decreaseScheduledWriteMessages();<a name="580" href="#580">580</a> }<a name="581" href="#581">581</a> <a name="582" href="#582">582</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> increaseScheduledWriteBytes(<strong class="jxr_keyword">long</strong> increment) {<a name="583" href="#583">583</a> scheduledWriteBytes.addAndGet(increment);<a name="584" href="#584">584</a> <strong class="jxr_keyword">if</strong> (getService() instanceof AbstractIoService) {<a name="585" href="#585">585</a> ((<a href="../../../../org/apache/mina/common/AbstractIoService.html">AbstractIoService</a>) getService()).increaseScheduledWriteBytes(increment);<a name="586" href="#586">586</a> }<a name="587" href="#587">587</a> }<a name="588" href="#588">588</a> <a name="589" href="#589">589</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> increaseScheduledWriteMessages() {<a name="590" href="#590">590</a> scheduledWriteMessages.incrementAndGet();<a name="591" href="#591">591</a> <strong class="jxr_keyword">if</strong> (getService() instanceof AbstractIoService) {<a name="592" href="#592">592</a> ((<a href="../../../../org/apache/mina/common/AbstractIoService.html">AbstractIoService</a>) getService()).increaseScheduledWriteMessages();<a name="593" href="#593">593</a> }<a name="594" href="#594">594</a> }<a name="595" href="#595">595</a> <a name="596" href="#596">596</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> decreaseScheduledWriteMessages() {<a name="597" href="#597">597</a> scheduledWriteMessages.decrementAndGet();<a name="598" href="#598">598</a> <strong class="jxr_keyword">if</strong> (getService() instanceof AbstractIoService) {<a name="599" href="#599">599</a> ((<a href="../../../../org/apache/mina/common/AbstractIoService.html">AbstractIoService</a>) getService()).decreaseScheduledWriteMessages();<a name="600" href="#600">600</a> }<a name="601" href="#601">601</a> }<a name="602" href="#602">602</a> <a name="603" href="#603">603</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">void</strong> decreaseScheduledBytesAndMessages(<a href="../../../../org/apache/mina/common/WriteRequest.html">WriteRequest</a> request) {<a name="604" href="#604">604</a> Object message = request.getMessage();<a name="605" href="#605">605</a> <strong class="jxr_keyword">if</strong> (message instanceof IoBuffer) {<a name="606" href="#606">606</a> <a href="../../../../org/apache/mina/common/IoBuffer.html">IoBuffer</a> b = (IoBuffer) message;<a name="607" href="#607">607</a> <strong class="jxr_keyword">if</strong> (b.hasRemaining()) {<a name="608" href="#608">608</a> increaseScheduledWriteBytes(-((IoBuffer) message).remaining());<a name="609" href="#609">609</a> } <strong class="jxr_keyword">else</strong> {<a name="610" href="#610">610</a> decreaseScheduledWriteMessages();<a name="611" href="#611">611</a> }<a name="612" href="#612">612</a> } <strong class="jxr_keyword">else</strong> {<a name="613" href="#613">613</a> decreaseScheduledWriteMessages();<a name="614" href="#614">614</a> }<a name="615" href="#615">615</a> }<a name="616" href="#616">616</a> <a name="617" href="#617">617</a> <strong class="jxr_keyword">protected</strong> <strong class="jxr_keyword">final</strong> <a href="../../../../org/apache/mina/common/WriteRequestQueue.html">WriteRequestQueue</a> getWriteRequestQueue() {<a name="618" href="#618">618</a> <strong class="jxr_keyword">if</strong> (writeRequestQueue == <strong class="jxr_keyword">null</strong>) {<a name="619" href="#619">619</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalStateException();<a name="620" href="#620">620</a> }<a name="621" href="#621">621</a> <strong class="jxr_keyword">return</strong> writeRequestQueue;<a name="622" href="#622">622</a> }<a name="623" h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -