I was looking for this, but I think I'm just confused.
What I'm trying to do is save a function pointer in an object and is called later in another thread.
What I represent is a constructor that will use a pointer to a function and the parameters that will be passed to this function pointer. This object will also have a run () method that will run the specified function pointer and a wait_until_completed () method, which blocks until the function is started.
A function pointer should be a function of another object, if that makes sense. for instance
Foo::*Bar(int);
I have wait_until_completed () working using pthread_cond_t, but I am stuck in a function pointer function in this function and feel like I'm just running in circles.
Any tips?
EDIT: This is for school (any general understanding of mine), so third-party libraries don't work: /
It seemed to me that I did a very poor job explaining this in order to give me a sample code (with the exception of all synchronization materials)
class Foo { public: Foo(void (Bar::*function) (int), int function_param) {
This is briefly what I am trying to do. However, I’m not sure if this is the syntax or I’m stupid, but I can’t figure out how to actually do this and force it to compile.
Thoughts? And thanks for all the advice so far :)
source share