Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signal implementation #4

Open
Xeenych opened this issue Oct 6, 2023 · 1 comment
Open

Signal implementation #4

Xeenych opened this issue Oct 6, 2023 · 1 comment

Comments

@Xeenych
Copy link

Xeenych commented Oct 6, 2023

Signal is implemented now as uint16_t.

So you need a big switch in dispatch() function to handle each signal and downcast<> template.

Signal could be implemented as function pointer void(*)() or even as a struct

struct {
void (*)(void*) func;
void* arg;
}

thus dispatch function will need to just call func(arg) without need to handle big switch operator

@quantum-leaps
Copy link
Contributor

quantum-leaps commented Dec 20, 2023

I presume that the proposed function pointers would point to the "event-handler" functions. This is problematic for several reasons.

First, the handling of an event depends on both the signal and the state of the receiving active object, so only one "event handler" won't do.

Second, the same event can be handled differently by different active objects, so again, one "event handler" won't do.

Third, the "event handler" function in general needs to access some additional data. This data is typically encapsulated inside the receiving active object. So, such a function would need to have access to such data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants