-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add guiding texts to examples and cleanup some things
- Loading branch information
Showing
30 changed files
with
218 additions
and
127 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
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Event Statistics Example | ||
|
||
This example showcases Ichor's capability to hook into the event loop system. It uses the pre- and post-event hooks to determine how long each event took to resolve and prints out the min/max/avg per event type at exit. | ||
|
||
It uses the `EventStatisticsService` provided by ichor, which in turn uses `preInterceptEvent` and `postInterceptEvent`. | ||
|
||
This demonstrates the following concepts: | ||
* Using the provided `EventStatisticsService` for performance measurements | ||
* Using the Timer subsystem to generate some artificial load to measure | ||
* How to implement ones own Event Interceptor service (see below) | ||
|
||
Implementing such a service yourself is also possible by calling the `registerEventInterceptor<>` function on the Dependency Manager: | ||
|
||
```c++ | ||
class MyClass { | ||
public: | ||
MyClass(DependencyManager *dm) { | ||
// register the interceptor and keep a reference it, as the destructor automatically unregisters it. | ||
_interceptorRegistration = dm->registerEventInterceptor<Event>(this, this); | ||
} | ||
|
||
void preInterceptEvent(Event const &evt) { | ||
// We don't need to check for evt.id or evt.type here, as postInterceptEvent() is guaranteed to be called directly after processing the event | ||
// The downside is then that each async execution point of an event is counted as a separate instance. I.e. every co_await is a new event with its own processing time. | ||
_startProcessingTimestamp = std::chrono::steady_clock::now(); | ||
} | ||
|
||
void postInterceptEvent(Event const &evt, bool processed) { | ||
auto now = std::chrono::steady_clock::now(); | ||
auto processingTime = now - _startProcessingTimestamp; | ||
fmt::print("Processing of event type {} took {} ns", evt.name, std::chrono::duration_cast<std::chrono::nanoseconds>(processingTime).count()); | ||
} | ||
|
||
private: | ||
EventInterceptorRegistration _interceptorRegistration{}; | ||
std::chrono::time_point<std::chrono::steady_clock> _startProcessingTimestamp{}; | ||
}; | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# HTTP Example | ||
|
||
This example starts up an HTTP server and an HTTP client that connects to said server. The client sends a JSON message to which the server responds and then quits. | ||
|
||
This demonstrates the following concepts: | ||
* Defining and using serializers | ||
* How to set up an HTTP server | ||
* How to set up an HTTP client using the `ClientFactory` | ||
* Using the advanced parameter `Spinlock` in the `MultimapQueue`. | ||
|
||
## Command Line Arguments | ||
|
||
```shell | ||
-a, --address, "Address to bind to, e.g. 127.0.0.1" | ||
-v, --verbosity, "Increase logging for each -v" | ||
-t, --threads, "Number of threads to use for I/O, default: 1" | ||
-p, --spinlock, "Spinlock 10ms before going to sleep, improves latency in high workload cases at the expense of CPU usage" | ||
-s, --silent, "No output" | ||
``` | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Minimal Example | ||
|
||
This example shows how to set up and quit an Ichor program | ||
|
||
This demonstrates the following concepts: | ||
* How to create the Queue and DependencyManager | ||
* How to register your own services | ||
* How to use the Timer subsystem | ||
* How to quit the program from within the event loop |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Multithreaded Example | ||
|
||
This example shows how to use multiple DependencyManagers on multiple threads and how to communicate safely between the two. | ||
|
||
This demonstrates the following concepts: | ||
* Creating multiple queues and DependencyManagers | ||
* How to use the `CommunicationChannel` to communicate between different queues | ||
* How to tell a different DependencyManager/queue to quit |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Optional Dependency Example | ||
|
||
This example shows how to use optional dependencies, including multiple of the same type. | ||
|
||
This demonstrates the following concepts: | ||
* Requesting optional dependencies, separate from the lifecycle of the requesting service | ||
* Normally, a service does not start until all of its required dependencies are met. Optional dependencies can come and go without starting/stopping the requesting service | ||
* How to handle multiple dependencies of the same type |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Realtime Example | ||
|
||
This example shows how Ichor behaves in a more real-time environment. It also includes code for Linux to increase the chance of meeting execution deadlines. |
Oops, something went wrong.