Created
January 31, 2018 15:04
-
-
Save DmitryOlshansky/873a198eaf27061f00cdea776884cca5 to your computer and use it in GitHub Desktop.
Out of band signal
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
// Consider that we spin up one of these guys per file | |
// the idea is that we can interrupt this fiber by sending Control message | |
// that will be processed out of bounds | |
void logFileProcessor(Stream!Control controlPlane, File inp) | |
{ | |
bool done = false; | |
auto source = inp.byLine; // | |
while(!done){ | |
multiplex( // pick one of sources that are ready and execute branches | |
controlPlane, { | |
// controlPlane is ready - assume this means termination | |
done = true; | |
} | |
source, { | |
// source is ready | |
if (source.empty) done = true; | |
else { | |
auto line = source.front; | |
scope(exit) source.popFront(); | |
.... // do things with line | |
} | |
} | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment