Event struct via registers

Basile B. b2.temp at gmx.com
Sat Aug 10 18:18:49 UTC 2024


On Saturday, 10 August 2024 at 07:46:46 UTC, Vitaliy Fadeev wrote:
> ## Trouble 1
>
> Pass the structure through registers ?
>
> [...]
>
> How to implement on D?

You dont need to pass whole event. The obvious design for this 
kind of things is that you declare a local event that's an union 
of all possible things then in the low level event loop you 
dispatch the members of interest to the high level consumer.

This is for example how this worked in kheops:

1. low level event loop with the big local union (an XEvent): 
https://gitlab.com/basile.b/kheops/-/blob/master/src/kheops/control.d?ref_type=heads#L2770

2. example of dispatching where only the usefull things are 
passed: 
https://gitlab.com/basile.b/kheops/-/blob/master/src/kheops/control.d?ref_type=heads#L2863

3. then the high level consumers just receive the useful 
parameters: 
https://gitlab.com/basile.b/kheops/-/blob/master/src/kheops/control.d?ref_type=heads#L752

That's always 3 or 4 parameters, always passed in general purpose 
registers.

I've never seen these kind of things done differently because it 
would indeed be slow to pass the whole event.


More information about the Digitalmars-d-learn mailing list