Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andsmedeiros/fuss
Efficient in-process pub/sub pattern for C++
https://github.com/andsmedeiros/fuss
Last synced: 2 months ago
JSON representation
Efficient in-process pub/sub pattern for C++
- Host: GitHub
- URL: https://github.com/andsmedeiros/fuss
- Owner: andsmedeiros
- License: mit
- Created: 2022-01-06T12:58:04.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-11T15:09:58.000Z (about 3 years ago)
- Last Synced: 2024-10-26T23:55:13.285Z (3 months ago)
- Language: C++
- Homepage:
- Size: 4.88 KB
- Stars: 13
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesomecpp - fuss - - efficient in-process pub/sub pattern for C++. (Concurrency)
README
# FUSS
FUSS is a simple and efficient pub/sub pattern implementation aimed for C++17 programs with an intuitive interface.
It consists of a single header file and has no external dependencies.## Features
- Simple, efficient, small and elegant. Just read the code!
- Leverages modern C++ to provide an intuitive and pleasant API.
- Avoids unnecessary dynamic memory as much as possible.
- No virtual functions.
- No RTTI.## Example
```C++
#include// Define what messages are available to be published.
struct greeting : fuss::message<> {};// Note that messages can have parameters.
struct echo : fuss::message {};// Create a publisher object
struct noisy : fuss::shouter {
void greet() {
// Publishes the `greeting` message.
// `shout()` is protected, so we create a member function to call it
shout();
}void repeat(const std::string &s) {
// Publishes the `echo` message with a string as parameter
shout(s);
}
};// Instantiate the publisher
noisy n;// Subscribe to the messages
auto greeting_listener = n.listen([]() {
std::cout << "Hello world!" << std::endl;
});n.listen([](std::string s) {
std::cout << s << std::endl;
});n.greet(); // prints 'Hello world!'
n.repeat("What a fuss!"); // prints 'What a fuss!'// Unsubscribe from a message
n.unlisten(greeting_listener);n.greet(); // doesn't print anything
```
## Copyright
Copyright André Medeiros 2022
Contact: [email protected]