kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #22383
Re: KiCad Coroutines
Lorenzo Marcantonio <l.marcantonio@xxxxxxxxxxxxx> writes:
> On Thu, Jan 07, 2016 at 12:08:22PM +0000, Mário Luzeiro wrote:
> Some thing like this:
> - Select a tool (suspend for a selection)
> - Other things happens, then user select a thing
> - (restart the tool coroutine) Check thing selected and so on
So to me, this sounds like an excellent use-case for co-routines.
I suppose the idea is to have code something like this (random pseudocode)?
a = some_prepare_tool_stuff();
b = other_stuff();
select = get_selection();
if (select.aborted) {
cleanup(a, b);
return;
}
more_tool_stuff(a, b, select.data);
The great thing about co-routines is that it allows to abstract things in
helper functions, like get_selection() above. You don't need to know exactly
how co-routine scheduling will happen inside get_selection, all the details
can be handled inside that function.
In contrast, without co-routines, every such usage will have to be split up
in multiple event handler / callback functions, at each point where event
handling can happen. This breaks the code flow, breaks the data flow, and
makes things a lot harder to read and understand.
Just my two cents,
- Kristian.
References
-
Re: KiCad Coroutines
From: Mark Roszko, 2016-01-04
-
Re: KiCad Coroutines
From: Torsten Hüter, 2016-01-04
-
Re: KiCad Coroutines
From: Mark Roszko, 2016-01-04
-
Re: KiCad Coroutines
From: Tomasz Wlostowski, 2016-01-06
-
Re: KiCad Coroutines
From: Wayne Stambaugh, 2016-01-06
-
Re: KiCad Coroutines
From: Torsten Hüter, 2016-01-07
-
Re: KiCad Coroutines
From: jp charras, 2016-01-07
-
Re: KiCad Coroutines
From: Lorenzo Marcantonio, 2016-01-07
-
Re: KiCad Coroutines
From: jp charras, 2016-01-07
-
Re: KiCad Coroutines
From: Mário Luzeiro, 2016-01-07
-
Re: KiCad Coroutines
From: Lorenzo Marcantonio, 2016-01-07