Mercurial Hosting > luan
comparison src/org/eclipse/jetty/io/nio/SelectorManager.java @ 942:c157a786ed0b
remove Timeout.Task
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Tue, 11 Oct 2016 00:41:39 -0600 |
| parents | b77d631b9e28 |
| children | 96f60ce98949 |
comparison
equal
deleted
inserted
replaced
| 941:c948f674a2d5 | 942:c157a786ed0b |
|---|---|
| 45 import org.eclipse.jetty.util.component.AggregateLifeCycle; | 45 import org.eclipse.jetty.util.component.AggregateLifeCycle; |
| 46 import org.eclipse.jetty.util.component.Dumpable; | 46 import org.eclipse.jetty.util.component.Dumpable; |
| 47 import org.slf4j.Logger; | 47 import org.slf4j.Logger; |
| 48 import org.slf4j.LoggerFactory; | 48 import org.slf4j.LoggerFactory; |
| 49 import org.eclipse.jetty.util.thread.Timeout; | 49 import org.eclipse.jetty.util.thread.Timeout; |
| 50 import org.eclipse.jetty.util.thread.Timeout.Task; | |
| 51 | 50 |
| 52 | 51 |
| 53 /* ------------------------------------------------------------ */ | 52 /* ------------------------------------------------------------ */ |
| 54 /** | 53 /** |
| 55 * The Selector Manager manages and number of SelectSets to allow | 54 * The Selector Manager manages and number of SelectSets to allow |
| 496 now=System.currentTimeMillis(); | 495 now=System.currentTimeMillis(); |
| 497 } | 496 } |
| 498 | 497 |
| 499 // workout how long to wait in select | 498 // workout how long to wait in select |
| 500 _timeout.setNow(now); | 499 _timeout.setNow(now); |
| 501 long to_next_timeout=_timeout.getTimeToNext(); | |
| 502 | 500 |
| 503 long wait = _changes.size()==0?__IDLE_TICK:0L; | 501 long wait = _changes.size()==0?__IDLE_TICK:0L; |
| 504 if (wait > 0 && to_next_timeout >= 0 && wait > to_next_timeout) | |
| 505 wait = to_next_timeout; | |
| 506 | 502 |
| 507 // If we should wait with a select | 503 // If we should wait with a select |
| 508 if (wait>0) | 504 if (wait>0) |
| 509 { | 505 { |
| 510 long before=now; | 506 long before=now; |
| 629 // Everything always handled | 625 // Everything always handled |
| 630 selector.selectedKeys().clear(); | 626 selector.selectedKeys().clear(); |
| 631 | 627 |
| 632 now=System.currentTimeMillis(); | 628 now=System.currentTimeMillis(); |
| 633 _timeout.setNow(now); | 629 _timeout.setNow(now); |
| 634 Task task = _timeout.expired(); | |
| 635 while (task!=null) | |
| 636 { | |
| 637 if (task instanceof Runnable) | |
| 638 execute((Runnable)task); | |
| 639 task = _timeout.expired(); | |
| 640 } | |
| 641 | 630 |
| 642 // Idle tick | 631 // Idle tick |
| 643 if (now-_idleTick>__IDLE_TICK) | 632 if (now-_idleTick>__IDLE_TICK) |
| 644 { | 633 { |
| 645 _idleTick=now; | 634 _idleTick=now; |
| 812 LOG.trace("",e); | 801 LOG.trace("",e); |
| 813 } | 802 } |
| 814 } | 803 } |
| 815 } | 804 } |
| 816 | 805 |
| 817 | |
| 818 _timeout.cancelAll(); | |
| 819 try | 806 try |
| 820 { | 807 { |
| 821 selector=_selector; | 808 selector=_selector; |
| 822 if (selector != null) | 809 if (selector != null) |
| 823 selector.close(); | 810 selector.close(); |
