Search found 12 matches

by flaviojs
Sat Jul 21, 2018 12:38 am
Forum: Programming
Topic: Add async threads
Replies: 13
Views: 1444

Re: Add async threads

Maybe it would be clearer if I package the pattern into a class? enum ProcessingTaskStatus { CREATED, RUNNING_IN_ASYNC_THREAD, SCHEDULED_FOR_GUI_THREAD, //< only when the task updates the UI RUNNING_IN_GUI_THREAD, //< only when the task updates the UI DONE }; class ProcessingTask : public std::enabl...
by flaviojs
Thu Jul 19, 2018 11:21 pm
Forum: Programming
Topic: Add async threads
Replies: 13
Views: 1444

Re: Add async threads

Probably log the error and attempt to continue. Then the current implementation is fine. It logs an error and the program continues, only the async thread terminates. ---- Since I don't know if the explanation should be here, I'll copy the explanation on how this works from the PR: Currently the ma...
by flaviojs
Tue Jul 17, 2018 5:27 am
Forum: Programming
Topic: Add async threads
Replies: 13
Views: 1444

Re: Add async threads

I submitted the most KISS alternative as a PR (https://github.com/freeorion/freeorion/pull/2219) and updated the initial post.

I think this approach is flexible and powerful, but there's still something I'm unsure about.
What should be done with unexpected exceptions in async threads?
by flaviojs
Fri Jul 13, 2018 3:06 am
Forum: Programming
Topic: Add async threads
Replies: 13
Views: 1444

ClientUI

I was trying to figure out where I should place read/write locking and other central thread-related facilities and got confused with ClientUI... It looks like ClientUI wanted to be a singleton but is not quite there (the ClientUI code does not guarantee 0-1 instances). HumanClientApp uses his own Hu...
by flaviojs
Wed Jul 11, 2018 6:41 pm
Forum: Programming
Topic: Add async threads
Replies: 13
Views: 1444

Re: Add a thread to Universe

I see that changes would propagate all the way to the AI client and server. However, freezing is essentially a GUI thing and they don't have a GUI, so a thread in Universe doesn't seem appropriate. Next I'll try isolating GUI to a separate thread or adding a worker thread to the GUI (whatever needs ...
by flaviojs
Tue Jul 10, 2018 10:03 pm
Forum: Programming
Topic: Add async threads
Replies: 13
Views: 1444

Re: Add a thread to Universe

I'm not sure what you mean by that, but if it's handled correctly now then it will probably be handled correctly with a Universe thread too.
(I intend to keep equivalent functionality)
by flaviojs
Mon Jul 09, 2018 11:06 pm
Forum: Programming
Topic: Add async threads
Replies: 13
Views: 1444

Re: Add a thread to Universe

Ok. It seems you're not against the idea of an asynchronous UI, so for now I'll give it a try and see it if it's feasible and appropriate.
by flaviojs
Mon Jul 09, 2018 8:21 pm
Forum: Programming
Topic: Add async threads
Replies: 13
Views: 1444

Re: Add a thread to Universe

I thought Universe and the Managers in the universe folder were the game state, and that the rest of the code accessed and manipulates these.
Is there more?
by flaviojs
Mon Jul 09, 2018 12:15 pm
Forum: Programming
Topic: Add async threads
Replies: 13
Views: 1444

Add async threads

Short version: Add a permanent thread to Universe. That thread will execute all std::function<void(void)> that are added to a FIFO queue (scheduled). (edit) Use asynchronous threads to load and process data. When done, the async thread will add the UI updates to the GUI work queue. The GUI thread (...
by flaviojs
Sun Jul 08, 2018 2:40 pm
Forum: Programming
Topic: EffectsGroup scope = Source
Replies: 7
Views: 803

Re: EffectsGroup scope = Source

Thank you. This is probably only helpful to beginners, but I just realized it becomes easier to figure out if I try to read it with human language... "activation" can be read as "is active/enabled when the source is ..." "scope" can be read as "the targets are ..." I paid more attention to the Effec...
by flaviojs
Sat Jul 07, 2018 10:13 pm
Forum: Programming
Topic: EffectsGroup scope = Source
Replies: 7
Views: 803

Re: EffectsGroup scope = Source

I did review both of those pages before creating this post, but they did not clarify what 'scope = Source' could match, at least for me (someone that is new to it)... Maybe it's just a matter of getting used to the syntax, which apparently is non-intuitive to me. You imply that it does not match all...
by flaviojs
Sat Jul 07, 2018 8:02 pm
Forum: Programming
Topic: EffectsGroup scope = Source
Replies: 7
Views: 803

EffectsGroup scope = Source

I'm trying to fully understand how EffectsGroup is used. From what I understood, scope is required and selects the targets that the EffectsGroup will affect. Looking at focs files I see scope = Source all over the place. I don't understand what it means when selecting targets... if it means all targ...