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
340 views

Is this a sane (as in lacking UB) implementation of a ref-counted subscription cleanup?

AutoCancel is a class which wraps a Cancel (aka void()) function. The purpose of wrapping ...
4 votes
1 answer
92 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
113 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
441 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
320 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 ...
1 vote
1 answer
609 views

Delphi - did I understand callbacks correctly?

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 ...
3 votes
2 answers
1k views

Wait for a callback and then using the result

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: ...
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 ...
7 votes
1 answer
520 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
243 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 ...
0 votes
0 answers
1k views

Add to Favourite List example - working but with performance issues

I am building a small framework for e-commerce or blog app using React. One of the features of this framework is an "Add to Favourite List" function. The ...
3 votes
1 answer
132 views

Cyclic generator with access to current local state and executes callback after each cycle

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 ...
1 vote
1 answer
69 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
66 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 ...
3 votes
2 answers
78 views

Simplify 2D point angle comparator

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 ...
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 ...
6 votes
2 answers
629 views

Error Code Stack Trace and Propagation Library in C

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 ...
3 votes
1 answer
110 views

Login system using callbacks in android

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 ...
2 votes
1 answer
417 views

Supplying parameterless callback to function expecting void * param

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, ...
4 votes
1 answer
2k views

Stateful function pointer for passing C++ capturing lambdas / std::functions to C style callbacks

...
42 votes
3 answers
44k views

Partitioning an array based on a condition in Javascript

Using the array.filter function, I can efficiently pull out all elements that do or do not meet a condition: ...
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 ...
1 vote
0 answers
74 views

AIPlaylist: Adaptive media player using VLCJ and Swing

I created a project using VLCJ and a probability function to create a media player that plays your favorite media more often than the others, because I wanted to hear my favorite music and videos more ...
0 votes
1 answer
59 views

Registering a user and login

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 ...
5 votes
2 answers
333 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
1 answer
69 views

Callback usage with custom Stack Exchange Flair

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 ...
3 votes
2 answers
599 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 ...
4 votes
1 answer
2k views

It's Teetime; adding tee like functionality to Popen

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 ...
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 ...
2 votes
2 answers
118 views

Bitmask, How to abstract those callbacks in this implementation

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 ...
5 votes
2 answers
118 views

Simple replacement for Redux in ES6

The idea about this code is that it's a full replacement of Redux — in 22 lines of code. ...
7 votes
1 answer
63 views

Apply arbitrary action during recursive generator function

I've got this recursive generator function. It will traverse an object looking for "leafs", any keys that don't point to sub-objects. Then it applies one of two actions on the leaf and yields it. Any ...
2 votes
0 answers
27 views

UI Event Flow class

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) ...
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 ...
2 votes
0 answers
29 views

Customizable unidirectional questionaire in javascript

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 ...
4 votes
1 answer
2k views

Wrap a callback method in an awaitable method

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 ...
3 votes
1 answer
86 views

Ajax function with a callback

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 ...
3 votes
1 answer
356 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. (...
1 vote
0 answers
25 views

Creating a reusable plugin (Dialog/Notifier as example)

I started working on a notification system that is pluggable into any project. I have not made any "plugin" type javascript libraries, usually just functions very specific to the project at hand. That ...
0 votes
1 answer
116 views

Chaining ConstrainableSet<T> [closed]

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 ...
1 vote
0 answers
72 views

C# asynchronous notification vector v2

As a result of my previous post, I have implemented / refactored my code and have started making successful use of my class. However I have come across a couple of new questions: The observer must ...
4 votes
1 answer
148 views

Constraining a property setter fluently

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 ...
10 votes
1 answer
695 views

ActivityLifecycleHelper implementation

Description The ActivityLifecycleHelper uses wrap(Context)to create the class and save a global ...
6 votes
1 answer
152 views

C# asynchronous notification vector

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 ...
4 votes
2 answers
8k views

Flattening multiple nested node readline questions

Say I'm creating a simple CLI. I want to use native node readline module to take in some input from user at prompt. I thought of this: ...
4 votes
2 answers
181 views

Function to call a list of callables with retry

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 ...
0 votes
1 answer
43 views

Updating one model field based on the associated model's field

I'm wondering if there is any way we can optimize the following code. Scenario is Library's active field should be ...