Created
March 15, 2016 18:40
-
-
Save benjaminmbrown/fb0b2535ff07c16e87e4 to your computer and use it in GitHub Desktop.
This file contains 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
/*pseudocode for event demultplexer*/ | |
socketA, pipeB; | |
watchedList.add(socketA, FOR_READ); | |
watchedList.add(pipeB, FOR_READ); | |
while(events = demultiplexer.watch(watchedList){ | |
foreach(event in events){ | |
/*non blocking read always returns data*/ | |
data = event.resource.read(); | |
if(data===RESOURCE_CLOSED){ | |
/*stop watching if resource closed*/ | |
demultiplexer.unwatch(event.resource); | |
} | |
else | |
consumeData(data); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment