Created
June 18, 2014 08:20
-
-
Save normanmaurer/368e34696447261c98ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Channel { | |
| private final Queue<Runnable> queue ... | |
| private final ChannelExecutor executor; | |
| .... | |
| public EventExecutor executor() { | |
| return executor; | |
| } | |
| private final class ChannelExecuter implements EventExecutor, Runnable { | |
| EventExecutor origin; | |
| public void execute(Runnable task) { | |
| queue.add(task); | |
| origin.execute(this); | |
| } | |
| public void run() { | |
| for (;;) { | |
| Runnable task = queue.poll(); | |
| if (task == null) { | |
| break; | |
| } | |
| task.run(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment