1006 */ |
1008 */ |
1007 public SecondaryLoop createSecondaryLoop() { |
1009 public SecondaryLoop createSecondaryLoop() { |
1008 return createSecondaryLoop(null, null, 0); |
1010 return createSecondaryLoop(null, null, 0); |
1009 } |
1011 } |
1010 |
1012 |
|
1013 private class FwSecondaryLoopWrapper implements SecondaryLoop { |
|
1014 final private SecondaryLoop loop; |
|
1015 final private EventFilter filter; |
|
1016 |
|
1017 public FwSecondaryLoopWrapper(SecondaryLoop loop, EventFilter filter) { |
|
1018 this.loop = loop; |
|
1019 this.filter = filter; |
|
1020 } |
|
1021 |
|
1022 @Override |
|
1023 public boolean enter() { |
|
1024 if (filter != null) { |
|
1025 dispatchThread.addEventFilter(filter); |
|
1026 } |
|
1027 return loop.enter(); |
|
1028 } |
|
1029 |
|
1030 @Override |
|
1031 public boolean exit() { |
|
1032 if (filter != null) { |
|
1033 dispatchThread.removeEventFilter(filter); |
|
1034 } |
|
1035 return loop.exit(); |
|
1036 } |
|
1037 } |
|
1038 |
1011 SecondaryLoop createSecondaryLoop(Conditional cond, EventFilter filter, long interval) { |
1039 SecondaryLoop createSecondaryLoop(Conditional cond, EventFilter filter, long interval) { |
1012 pushPopLock.lock(); |
1040 pushPopLock.lock(); |
1013 try { |
1041 try { |
1014 if (nextQueue != null) { |
1042 if (nextQueue != null) { |
1015 // Forward the request to the top of EventQueue stack |
1043 // Forward the request to the top of EventQueue stack |
1016 return nextQueue.createSecondaryLoop(cond, filter, interval); |
1044 return nextQueue.createSecondaryLoop(cond, filter, interval); |
1017 } |
1045 } |
1018 if (fwDispatcher != null) { |
1046 if (fwDispatcher != null) { |
1019 return fwDispatcher.createSecondaryLoop(); |
1047 return new FwSecondaryLoopWrapper(fwDispatcher.createSecondaryLoop(), filter); |
1020 } |
1048 } |
1021 if (dispatchThread == null) { |
1049 if (dispatchThread == null) { |
1022 initDispatchThread(); |
1050 initDispatchThread(); |
1023 } |
1051 } |
1024 return new WaitDispatchSupport(dispatchThread, cond, filter, interval); |
1052 return new WaitDispatchSupport(dispatchThread, cond, filter, interval); |