Replies: 1 comment 3 replies
-
I'm not sure that this needed another issue to track the discussion - I would have thought either the issue where the work is ongoing, or a design document. But as it's here I will comment on what was added: The above description covers how we could fix a lot of issues for the main usage (to migrate to a single thread) which was the work already begun and documented on #4654. However it assumes that anyone launching a goroutine is required absolutely to manage the thread lifecycle by calling extra methods to pass in. This is pretty much the easiest thing for us to do, but puts a large cognitive load onto developers that I have always intended to avoid and even promised that everything just works the way you think it should. Perhaps we need to make a progressive approach,
I think that covers everything and allows us to make progress quickly but move to the simplistic API nirvana over time... |
Beta Was this translation helpful? Give feedback.
-
As the discussions and planning for #4654 continue, I thought I'd try to sketch out a partial requirements list. I think whatever model is decided, it will need to be able to meet these criteria at a minimum, so this is a good starting point for evaluating designs:
The model needs to specify how the following things can be accomplished safely and race-free from a user-spawned goroutine. (This is a partial list)
To start, with the hypothetical single-threaded model where all APIs are invoked from the same goroutine, the answer for # 1-4 is:
If in a user-spawned goroutine, run
If not in a user-spawned goroutine, we guarantee you will already be on the "app" goroutine (ie every callback from Fyne to user code occurs on this goroutine, so it is automatically safe to just directly invoke any API.
And the answer for # 5 is you don't have to do anything special, since you know your users will be calling your APIs from a single goroutine, because doing otherwise goes against the guarantees the model provides
Beta Was this translation helpful? Give feedback.
All reactions