Skip to main content

Questions tagged [callback]

Callback is facility to save a piece of code so that it may be invoked later in the current environment (Typically in response to an event)

Filter by
Sorted by
Tagged with
4 votes
1 answer
357 views

AutoCancel is a class which wraps a Cancel (aka void()) function. The purpose of wrapping ...
smac89's user avatar
  • 1,539
4 votes
1 answer
177 views

I've started to write a header-only implementation of callback for member functions : ...
hl037_'s user avatar
  • 141
1 vote
1 answer
172 views

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 ...
Hamza Hajeir's user avatar
6 votes
2 answers
493 views

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 ...
Diederick C. Niehorster's user avatar
2 votes
1 answer
375 views

Although this code uses ros2 my concern is about C++ code quality, because I still struggle when it comes to making good design ...
Sam Hammamy's user avatar
1 vote
1 answer
676 views

I am trying to learn callbacks in Delphi (7). Could not find a complete simple tutorial, so I puzzled together a few bits here and there. This is my first attempt, of course trivial. My form contains ...
MyICQ's user avatar
  • 113
3 votes
2 answers
1k views

I'm using Frida to run a script on a process, and I want to wait for it to send the result back to me, as a callback. My current code looks like this: ...
JJTech's user avatar
  • 79
7 votes
1 answer
559 views

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 - ...
Lex's user avatar
  • 71
2 votes
1 answer
263 views

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 ...
FatalSleep's user avatar
1 vote
1 answer
128 views

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 ...
Diederick C. Niehorster's user avatar
1 vote
1 answer
111 views

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 ...
Diederick C. Niehorster's user avatar
2 votes
1 answer
1k views

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 ...
Shigoto Shoujin's user avatar
1 vote
2 answers
1k views

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 ...
Michael's user avatar
  • 13
3 votes
2 answers
128 views

I have a comparison function for comparing two points in 2 (or more) dimensions based on the angle of each point in standard polar coordinates. In other words, a point ...
hacatu's user avatar
  • 472
7 votes
3 answers
2k views

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 ...
fededevi's user avatar
  • 330
1 vote
1 answer
1k views

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. ...
Diederick C. Niehorster's user avatar
3 votes
1 answer
4k views

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 ...
Diederick C. Niehorster's user avatar
3 votes
1 answer
159 views

I'm working on a Python class that is a cyclic generator, like itertools.cycle, but it offers access to its current state and executes a callback after the ...
Кафка's user avatar
6 votes
2 answers
696 views

I've been programming in Go and I enjoy how easy it is to create descriptive errors and propagate them up the call stack. I wanted that sort of ease and consistency in C so I created a small error ...
Ollie's user avatar
  • 163
2 votes
1 answer
481 views

I have to register different callback functions to a scheduler. The callback signature defines a void * parameter. Some callbacks don't use a parameter. This works, ...
robsn's user avatar
  • 121
3 votes
1 answer
126 views

I wrote a login system for an app I am developing, but I'm not really happy with the code I have at the moment. I feel like there is a better way at tackling a problem like this. In particular I'm not ...
RuuddR's user avatar
  • 131
3 votes
1 answer
2k views

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 ...
mmcblk1's user avatar
  • 33
0 votes
1 answer
82 views

I have these following controller functions for registering a user and login, in my app, and I want to make it more clean and maintainable. Probably by using ...
ubuntu7788's user avatar
5 votes
2 answers
407 views

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 ...
M2tM's user avatar
  • 146
3 votes
2 answers
660 views

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 ...
shangaoren filehunter's user avatar
4 votes
1 answer
2k views

I recently needed to run some command line applications from Python. Whilst this is fairly simple with subprocess.Popen. I wanted to be able to properly pipe the ...
Peilonrayz's user avatar
  • 44.6k
2 votes
2 answers
173 views

I've made an POC about a bitmask implementation in order to replace a huge if/else statement. Those statements are about strings and I have almost 15 /20 string to test. Depends on values the if/else ...
Hooli's user avatar
  • 181
5 votes
2 answers
145 views

The idea about this code is that it's a full replacement of Redux — in 22 lines of code. ...
Merc's user avatar
  • 531
13 votes
2 answers
5k views

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 ...
KeyC0de's user avatar
  • 233
2 votes
0 answers
41 views

I wrote the below answer for the following question on SO a couple of days ago, and I was curious if the usage of the generator function is an acceptable one. I choose the generator function, because ...
Icepickle's user avatar
  • 825
3 votes
1 answer
95 views

Today I decided to continue refining my JavaScript skills and utilized the Stack Exchange API (v2.2) to write a "user flair" replica. In case you don't know what the flair that SE provides is: The ...
Taco's user avatar
  • 929
3 votes
1 answer
109 views

I have Ajax function with a callback which fetches all the Patient data however I have some perfomance issues and trying to figure out what it might be, does anyone have idea? That's my Code ...
Mike J's user avatar
  • 33
3 votes
1 answer
402 views

An alternative to std::function for when compile time is more important than runtime performance. Doesn't pull in any headers. (...
Taylor's user avatar
  • 287
4 votes
1 answer
2k views

I'm using a .NET library which uses a pre-async/await type of asynchronicity. That is, it provides asynchronous (non-awaitable) method with a callback parameter. I'm trying to write awaitable ...
41686d6564's user avatar
0 votes
1 answer
163 views

Based on feedback on my previous question, I made many small adjustments to the code, added more APIs and tried to follow through with delivering on the excellent advice I have received in regards to ...
BanMe's user avatar
  • 75
4 votes
1 answer
181 views

The below code is aimed at providing you the most amount of control and flexibility with control which value gets set to a property. I Introduce to you, the ...
BanMe's user avatar
  • 75
6 votes
1 answer
200 views

The purpose of this class is to efficiently notify another thread when data is available with minimal blocking to access/pass the data. The data reader/producer thread processes data in bulk which ...
sfanjoy's user avatar
  • 223
2 votes
0 answers
37 views

Purpose: I wanted a way to improve event clarity and event code organization. I observed that every single event flow went through the following steps: Trigger -> UI Change -> (Async) ...
Shelby115's user avatar
  • 1,971
4 votes
2 answers
216 views

This script is designed to be run via windows task scheduler once per day. All callables passed to this function should only return a bool. The callables are called until either the maximum number of ...
Dave's user avatar
  • 753
0 votes
1 answer
63 views

I'm wondering if there is any way we can optimize the following code. Scenario is Library's active field should be ...
Bibek Sharma's user avatar
4 votes
3 answers
7k views

I am new to Java and had some difficulty creating this simple Publisher Subscriber class. It finally seems to be working and I wanted to check if I have been following best practices and see if there ...
KNejad's user avatar
  • 171
3 votes
1 answer
4k views

I'm creating a window class in C++ to provide a bit of abstraction for a GLFW window. window.h ...
Cortex's user avatar
  • 440
0 votes
1 answer
2k views

In my web application, a user will click a button which will call a function that triggers an AJAX call. That function accepts a single argument. I would like to be able to put that function in ...
Aaron Goldsmith's user avatar
5 votes
2 answers
183 views

I was asked to complete the task described below: Event Emitters are objects that serve as the core building block in event-driven architectures. They simplify the process of handling asynchronous ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
3 votes
2 answers
195 views

I am working on a university project that consists of creating a map application with openlayers as well as the necessary User-Interface. I am using jQuery, native JavaScript, PHP and of course HTML/...
phloose's user avatar
  • 31
6 votes
1 answer
5k views

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 ...
NutCracker's user avatar
1 vote
2 answers
113 views

Here is a class I wrote to provide a user a way to have a callback function executed at some defined frequency: Task.hpp ...
Clay Brooks's user avatar
2 votes
1 answer
601 views

I have a function which returns an array of datasets for a chart written with vue-chartjs. The getter getChartData returns an array with three objects with nested ...
Olga B's user avatar
  • 155
2 votes
0 answers
77 views

I have been developing this structure or pattern (I don't really know how to call it). It's my first time doing something like this, and I'm a bit worried about the future, if it becomes unmanageable. ...
Vistor's user avatar
  • 43