-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📬 FtlServer event queue model (#102)
This change introduces a single-thread event queue model for `FtlServer` in order to minimize issues with deadlocks and out-of-order processing for sequential events. `FtlServer` now contains definitions for 11 events that can be processed: ```cpp enum class FtlServerEventKind { Unknown = 0, StopStream, // Request to stop a specific Channel / Stream ID NewControlConnection, // ConnectionListener has produced a ConnectionTransport ControlConnectionClosed, // FtlControlConnection has closed ControlRequestHmacKey, // Control connection requests HMAC key ControlHmacKeyFound, // HMAC key has been provided for a Control connection ControlRequestMediaPort, // Control connection requests media port TerminateControlConnection, // Terminate and remove a Control connection StreamIdAssigned, // StreamStartedCallback has returned a Stream ID StreamStarted, // FtlStream has started successfully StreamStartFailed, // FtlStream has failed to start StreamClosed, // FtlStream has closed }; ``` Each event has an event payload that derives from `FtlServer::FtlServerEvent`. When `FtlServer` is constructed, a jthread is initialized to process event queue events. When `FtlServer` is destructed, the `stop_token` is set on the jthread, stopping the event queue, and the jthread is joined. Any public method exposed by `FtlServer` will enqueue an event in the queue to ensure events are processed in the intended order, and to avoid blocking the caller. Similarly, any outgoing call will be processed on a new jthread via `dispatchAsyncCall` to avoid blocking the event queue. These threads will be tracked by `FtlServer` and joined on destruction of the class or when they finish their task. Return values will be enqueued as a task in the event queue for further processing.
- Loading branch information
Showing
15 changed files
with
798 additions
and
265 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
[submodule "cpp-httplib"] | ||
path = cpp-httplib | ||
path = vendor/cpp-httplib | ||
url = https://github.com/yhirose/cpp-httplib | ||
[submodule "janus-ftl-orchestrator"] | ||
path = janus-ftl-orchestrator | ||
path = vendor/janus-ftl-orchestrator | ||
url = https://github.com/Glimesh/janus-ftl-orchestrator | ||
[submodule "vendor/eventpp"] | ||
path = vendor/eventpp | ||
url = https://github.com/wqking/eventpp.git |
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
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
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
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
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
Oops, something went wrong.