All Questions
44 questions
4
votes
1
answer
110
views
Member (virtual or not) function to C callback by generating static version at compile time
I've started to write a header-only implementation of callback for member functions :
...
1
vote
1
answer
121
views
C++ Structural Requests System with Payload Management
First things first, I'd thank Mr. G. Sliepen and Mr. Davislor regarding their help in the previous questions (C++ System data transfer design) (C++ System data transfer design - Following 1), given ...
6
votes
2
answers
449
views
c++ multithreaded message broadcaster with link lifetime management v3
note: This is v3 of code that was previously reviewed.
I have written a class that handles listeners registering callbacks to receive messages. Link lifetime is managed (or is it? See below). Code is ...
2
votes
1
answer
324
views
An NVIDIA Jetson Nano GPIO Wheel Encoder Message Publisher using ROS2
Although this code uses ros2 my concern is about C++ code quality, because I still struggle when it comes to making good design ...
7
votes
1
answer
538
views
TFunction: std::function replacement for event system
I've been trying to implement delegate for my event system. I thought that maybe std::function can do the trick for me, but it turned out to be not comparable, so what i have end up doing is this - ...
2
votes
1
answer
245
views
Event callbacks library
This is a small library I wrote to make event callbacks with variadic templates work like C#'s event system (placeholder template by "dyp" at http://stackoverflow.com/a/21664270).
Just like ...
1
vote
1
answer
74
views
c++ multithreaded message broadcaster with link lifetime management v2
note: This is v2 of code that was previously reviewed.
I have written a class that handles listeners registering callbacks to receive messages. Link lifetime is managed (or is it?). Code is ...
1
vote
1
answer
72
views
c++ multithreaded message broadcaster with link lifetime management
note: A version of this code without link lifetime management was previously reviewed. Adding lifetime management actually made the code simpler, and the class simpler to use.
I have written a class ...
2
votes
1
answer
1k
views
Generic Event class
C++ Event class
From the desire of having a callback function which includes a void* userdata argument, I've made this generic event class.
It is tested and working, but some desired features are ...
0
votes
2
answers
1k
views
C++ Observer Pattern with std::function
I am/we are using the observer pattern for many things in our application. I think it's time to create a reusable base class for these situations. Most implementations I could find only do something ...
7
votes
3
answers
2k
views
C++ Generic Callback class with removable listeners by unique id
I'm quite new to the STL.
Does this make sense? Is there a better way of removing the listeners instead of using shared_ptr while keeping the code short and simple? Is there something in the STL to ...
1
vote
1
answer
1k
views
c++ multithreaded message broadcaster using callbacks
note: This is an updated design after a previous review round.
I have written a class that handles listeners registering callbacks to receive messages. Registered callbacks can be replaced or removed. ...
3
votes
1
answer
4k
views
C++ callback multithreaded, can unregister itself
update: a new version of this code is posted here
With this post, i would like to 1) ask for feedback on below code as it stands:
do i apply all best practices for c++20?
is it safe?
is my way to ...
4
votes
1
answer
2k
views
3
votes
1
answer
2k
views
Callback C++ Class method from C
I am trying to callback C++ class methods from C. Now I have got something working, but am not sure if this is the best solution.
I am looking for feedback, as to if there is something wrong with this ...
5
votes
2
answers
335
views
Message Broadcaster
I've written a basic event messenger broadcasting service. This is meant to allow for broadcasting events between loosely coupled areas of code where you may not have or care about a direct reference ...
3
votes
2
answers
611
views
callback function with no dynamic memory allocation
I tried to make a callback type for embedded, I know std::function and lambda but I know that there is some dynamic memory allocation that I want to avoid, I came ...
13
votes
2
answers
5k
views
Implementation of a Thread Pool in C++
I wanted to implement a thread pool to test my knowledge of various modern C++ features. The end result could be better, but I need a review as I'm not sure about delicate things especially regarding ...
3
votes
1
answer
366
views
std::function alternative with no dependencies
An alternative to std::function for when compile time is more important than runtime performance. Doesn't pull in any headers.
(...
3
votes
1
answer
4k
views
C++ wrapper for GLFW window object
I'm creating a window class in C++ to provide a bit of abstraction for a GLFW window.
window.h
...
5
votes
1
answer
4k
views
Simple event dispatcher
Here is my very first event dispatcher. I would like to get both, style and code review, as well as some ideas to improve this implementation (new features etc.)
I tried to write code in C++17 style ...
1
vote
2
answers
75
views
Class that provides callback execution at a specified rate
Here is a class I wrote to provide a user a way to have a callback function executed at some defined frequency:
Task.hpp
...
6
votes
1
answer
3k
views
Simple implementation of signals and slots mechanism using templates
I tried to implement a simple signal&slots mechanism for some DSP software that runs on embedded Linux. I would like if somebody can review this code and give me some guidelines. Any review and ...
7
votes
1
answer
4k
views
Custom ostream for a println-like function
I am writing a plugin in C++ that uses C API that gives me a single logging function with this signature:
typedef void(*println_t)(const char* text);
I want to ...
3
votes
1
answer
2k
views
Use callback style to start a worker thread and receive result in Qt
After using JavaScript for a while, I think callbacks are pretty good for asynchronous programming, but I haven't seen anything similar in C++. What I want to achieve is to start a worker thread from ...
4
votes
1
answer
598
views
C++ regex_replace with arbitrary function
This is a version of C++17 regex_replace that handles arbitrary functions to do the replacement, instead of using regex_replace'...
1
vote
1
answer
2k
views
C++ event system
I created a simple C++ event system. In my code Event_channel is a static class that wraps singletons that manages events per event type basis. Every singleton ...
3
votes
0
answers
58
views
Nisse Server: Part 5 Handler
Getting close to a release of generic server.
Nisse Server: Part 1 Helper Functions
Nisse Server: Part 2 Socket Layer
Nisse Server: Part 3 Stream Layer
Nisse Server: Part 4 Server
As I mentioned ...
3
votes
0
answers
279
views
Simple C++11 Subject-Observer
Building on the answer in C++ class member callback simple examples, I've tried to put together a simple subject-observer pattern without needing to inherit a virtual Observer class. I also wanted to ...
6
votes
1
answer
2k
views
Request and callback design
I am just trying to improve my coding and designing skills in C++ and for that
I am trying to solve same age old problem of mapping a http request to method.
Could you guys please look at my program ...
9
votes
1
answer
4k
views
Simple callback wrapper for an embedded C++ app
I'm writing a callback wrapper class for an embedded application in C++11.
The basic idea of the class is to be able to use it as a replacement instead of C-style callback functions, with the added ...
2
votes
1
answer
945
views
Callback class to callback member (virtual) functions
After looking at a post on CR I found that pointers to member functions are incredibly hard to use, especially as callbacks. The current solution doesn't solve the problem mentioned in the linked post,...
3
votes
2
answers
873
views
Callback system for events in a window
I have written a simple window event capture wrapper that gets events that happen to the window, and can be checked anywhere in the program through a global class. I wanted to be able to create a ...
4
votes
1
answer
119
views
Invocation list implementation (signals/slots)
This class is mostly an educational exercise for me using some C++11 constructs. I wanted to create something similar to an "invocation list" in C#, i.e., a list of zero or more function objects which ...
1
vote
1
answer
2k
views
TCP client library using Winsock WSAEventSelect in C++ - Take 2
This is my second take on creating a tcp client C++ class. The class declaration is general but the implementation is Windows only at this stage and uses the Microsoft Winsock WSAEventSelect model.
...
2
votes
1
answer
1k
views
TCP client library using Winsock WSAEventSelect in C++
One way to write a client which uses a specific protocol, eg http like in this case, is to create a base class with the basic socket handling functionality with virtual functions which can be ...
3
votes
0
answers
1k
views
C++ UDP server for a game
I broke my server into two classes, a general server class and a client session class.
I know the code isn't documented in the header, but I am more interested in the design of the server/session ...
11
votes
1
answer
3k
views
C++14 Event System
I've created a simplified event system for C++14. The code is commented, so it shouldn't be hard to read. There's also a simple usage scenario below.
It is still a work in progress and uses some not-...
4
votes
2
answers
1k
views
C++ EventHandler class, invoking & arguments
This is my EventHandler class, which is extremely simple and can be used on lambdas and similar:
...
21
votes
2
answers
15k
views
C++ Observer design pattern implementation
I'm using the Observer design pattern in order to manage events in the game I'm currently developing.
I based myself on the implementation demonstrated here but improved it in order to ease its use.
...
10
votes
2
answers
6k
views
C-ifying a capturing lambda
What do you think of this code?
...
4
votes
0
answers
935
views
Aysnc call back to UI Thread
My main DLL is a .Net one that has an async running method and fires an event when it's done:
...
2
votes
2
answers
179
views
Conditional functions or multiple similar definitions?
In my program(C++), I'm going to use callback functions to process input from the keyboard and mouse and constantly draw a scene. How these functions process information will change depending on the ...
4
votes
1
answer
4k
views
Fast templated call back implementation
Below is the code for my templated callback implementation. Currently it works for a single parameter. One thing I was going to try and do next was increase the argument to the function from 1..N ...