Make a "use std::optional" patch and then rebase
- Queries
- All Stories
- Search
- Advanced Search
- Transactions
- Transaction Logs
Advanced Search
Oct 16 2022
The core difference is that there is a pirority queue of timed tasks instead of a pool of repeating tasks.
My idea can be implemented either way. (Using the worker threads or make a timed thread)
Oct 15 2022
Comments from stan and wraitii
In D3877#204445, @wraitii wrote:In D3877#204125, @phosit wrote:I have a different idea:
A ThreadPool::runAfter(timePoint, timedTask) which pushes the timedTask to a new queue priority_queue<pair<timePoint, timedTask>>. Ordered only by .first.
So there is no need for a extra timerThread and there is no restriction in how long the task can take.Part of the point of my timer thread is to try to use woken threads, to avoid waking up costs. Would your idea give the same benefit ?
Oct 14 2022
Should there be a RAII wrapper?
Oct 10 2022
In D4770#204298, @mbusy wrote:In D4770#204068, @phosit wrote:Yes it works as you described.
Some things i would change:
- Single-player > Matches > Load Game directly starts a game. Multiplayer > Host Game > Load Game does not. This should be consistent.
I did that to give the players (in multiplayer mode) the possibility to edit the settings a bit before launching the saved game, to make sure that everyone has the correct civ. I don't really think that it's useful for single player though, as you will always fall back on the civ that you were playing. I could very well remove the load game button for the single player setup menu (I'll bring that up again in one of the following points)
Oct 9 2022
@wraitii I'm thinking about only moving m_Kill, m_Mutex and m_ConditionVariable to Impl and don't do anything to PopTask. The advantage over the current state would be that we can call notify_one.
Oct 8 2022
In D4796#204255, @vladislavbelov wrote:I don't get what you meen by that.
I mean we could have a class that might accept an arbitrary type and bind it properly to renderer backends. For example:
class CShaderProgramGraphicsContext : ... { public: CShaderProgramGraphicsContext(Renderer::Backend::IDeviceCommandContext* deviceCommandContext) // ... void SetUniform(const ReloadableHandle handle, const CColor& color) { m_DeviceCommandContext->SetUniform(GetBindingSlot(handle), color.AsFloatArray()); } // ... };
In D4796#204253, @vladislavbelov wrote:In D4796#204247, @phosit wrote:There should be a SetUniform which takes a Vector2D to initialize(conceptualy) a vec2.
Yeah, I was thinking about that as well. But the renderer backend shouldn't know about client types.
span is also a client tybe. ;)
In D4796#204236, @vladislavbelov wrote:In D4796#204232, @Stan wrote:Shouldn't the description be use vec4 + vec2 instead of mat2?
Semantically I use mat2, but I pass it via vec4 to save binding slots.
last version contained changes to extract.pl
Oct 7 2022
There are errors if i go to Multiplayer > Host Game > Continue and then press Back or Start Game!.
Lint; 2 -> 2.f
I selected the wrong reposetory
Do only one thing... It is easyer to review.
Oct 6 2022
In ChildrenMap the elements are lexicographic orderd. Do we expect "Entity" and "test" to be the lexicopraphic first child?
If we expect the node to have only one child, you should ENSURE that.
Oct 5 2022
In D4786#204109, @wraitii wrote:It seems odd to me that the state hash check would be so slow to be honest.
Revert parameter reordering.
Oct 3 2022
I have a different idea:
A ThreadPool::runAfter(timePoint, timedTask) which pushes the timedTask to a new queue priority_queue<pair<timePoint, timedTask>>. Ordered only by .first.
Since it is a single(cheap) comparison timedTasks.top().first < now multiple/every workerThread could check.
So there is no need for a extra timerThread and there is no restriction in how long the task can take.
ThreadPool::addRecurrentTask can be implemented in terms of ThreadPool::runAfter:
Oct 2 2022
In D4786#204089, @wraitii wrote:You can actually execute this in a replay with -hashtest-full=true and -hashtest-quick=true if you make it an MP replay.
Sep 30 2022
Yes it works as you described.
Some things i would change:
- Single-player > Matches > Load Game directly starts a game. Multiplayer > Host Game > Load Game does not. This should be consistent.
- Differentiate singlesplayer saves and multiplayer saves a bit more. Propably like the replays. Single-Player > Matches > Load Game by default only shows single-player saves but with a dropdown Multiplayer games can also be shown.
- As we have Single-player > Matches > Load Game we should remove Single-player > Load Game. Some player may wonder if there is a difference.
Sep 28 2022
In D4770#204058, @mbusy wrote:@phosit mh weird... I have been using this patch both from a windows desktop and an unbutu desktop, and played with a friend using it... What configuration do you use? What crash message do you obtain? I'll try to replicate your crash. I also wondered if this could be due to the fact that the patch is based on a slightly older version of the project (a month ago or so), I'll try to apply it with a more recent version of the project
Valgrind reports uninitialized reads. m_EndsWithSpace is sometimes not initialized.
Sep 25 2022
It does not work for me: as soon as i hit Save as a host of a MP game the game crashes. Same for the Load Game button.
I'm not satisfied with the "selecting priority" inside PopTask. The predicate is not trivial and both mutexes are owned at the same time. Do you think this are problems? Do you have a solution?
My ideas (non of them is perfect and i omited m_Kill):
Sep 24 2022
Sep 9 2022
Sep 8 2022
change parameter order of PushTask
add context
In D4425#203777, @Stan wrote:Can't you make it the responsibility of the receiver to destroy objects instead of adding the extra overhead of a unique ptr?
Revert to the one that worked
Sep 7 2022
In D4425#203777, @Stan wrote:Can't you make it the responsibility of the receiver to destroy objects instead of adding the extra overhead of a unique ptr?
I guess an overkill solution could also be to have a destruction queue that's emptied when trying to push new tasks.
fix the actual memory leak bug
fix the memory leak
apply suggestions from Stan
Sep 6 2022
Use Future to comunicate the return value and to ensure the task is stoped in the destructor.
Sep 5 2022
Sep 4 2022
In D4784#203715, @vladislavbelov wrote:A namespace can't have I prefix, because it's not an interface. As it doesn't provide a contract. Which means using namespace in such manner is much more error prone than using a real interface.
The name can also be changed.
I tried to only remove the down-casts.
Sep 2 2022
I apologise to thous who put time in reviewing.
For now we should put ower time in improving Future and TaskManager.
When we have coroutines we should again take a look at this interface. When all compilers support coroutines we can also use libunifex.
On a second thought someone might expect the profiler to have a livetime like std::clog. Wen using CProfiler in static initialization there would be an dangling reference.
I think it would be bether to have components (HTTP / GPU) be handled by RTTI. Propably I do that in an other diff.
Aug 31 2022
The code in GUI is easier. But there is duplicate in Canvas2D.cpp. Could DrawRotatedTexture just compute the rotated destination and call DrawTexture
Aug 28 2022
Aug 27 2022
The new naming makes sense.
Does anybody know why it was called m_HostId before?
The code is reasonable ✓
The bug is fixed ✓
The test pass ✓, and don't pass if the actual fix is not applied ✓
I don't see any new text missalignement ✓
Aug 25 2022
Aug 24 2022
In D4751#203259, @Stan wrote:@phosit it seems one cannot cast from const_iterator aka _Array_const_iterator to T* any clue?
Well the C++ standard does not specify that const_iterator is convertible to T*.
Aug 22 2022
In rP26915#58739, @wraitii wrote:What menu is that?
Aug 21 2022
CI failed
fix windows build
We could go even further and remove PackagedTask. The TaskManager then would hold std::shared_ptr<ErasedSharedState>
coments from Stan and copyright year
Aug 20 2022
In D4766#203069, @jprahman wrote:From a 40,000ft view, libraries like libunifex already implement similar sender-receiver functionality à la the wg21 P2300 paper. Are there particular advantages of adding our own implementation of a subset of p2300 vs. adopting a library like libunifex which offers a much broader set of functionality?
I don't think that we want to depend on another library. Libutifex requires a newer compiler than we do.
If libunifex gets more approval, I'm in. After all we also have {fmt}.
Aug 19 2022
- template Future on return type.
- use std::optional
- Future does not implicitly convert the result type into its stored-type. That was considered a feature.
An other arguments ;)
The syntax for recurrent tasks https://code.wildfiregames.com/D3877 would be easy: syncWait(taskManager.schedule() | task | repeatAfter(duration)).
Aug 18 2022
In D4768#202989, @vladislavbelov wrote:In D4768#202986, @phosit wrote:And how well does your task manager work with zero threads?
Works fine as said above.
Sory that was only a rhetorical question. I thaught it would not work. seems task-cancelation works great.
- Free function -> make m_AvailableLocales a const member
- Rename member variables
- Return const reference from GetCurrentLocale
In D4768#202987, @Stan wrote:numberOfWorkers < MIN_THREADS is perfectly fine.
Well it is only because of the cassert you added preventing MIN_THREADS to be 0. But then you have a logic flaw. If it can be lower than MIN_THREADS then MIN_THREADS is not the minimum bound and its name is incorrect.
Currently the name is also not perfect. It Should be MIN_WORKER.
Pyrogenesis uses between MIN_THREADS and MAX_THREADS threads. If the sound manager and userreporter and... would use TaskManager. :)
In D4768#202985, @vladislavbelov wrote:In D4768#202981, @phosit wrote:static_assert(MIN_THREADS > 0 && MIN_THREADS <= MAX_THREADS); numberOfWorkers = Clamp(std::thread::hardware_concurrency(), MIN_THREADS, MAX_THREADS) - 1;As pointed by Stan it's wrong.
No Stan also didn't understand me. I think i'm the problem :(
numberOfWorkers < MIN_THREADS is perfectly fine.
In D4768#202983, @Stan wrote:Should be:
cassert(MIN_THREADS > 0 && MIN_THREADS <= MAX_THREADS); numberOfWorkers = Clamp(std::thread::hardware_concurrency() - 1, MIN_THREADS, MAX_THREADS);Else you can get numberOfWorkers < MIN_THREADS
Thats the way it is implemented right now.
MIN_THREADS; MAX_THREADS and hardware_concurrency() also counts the main thread.
You suggest:
size_t GetDefaultNumberOfWorkers() { const size_t hardware_concurrency = std::thread::hardware_concurrency(); return hardware_concurrency ? hardware_concurrency - 1 : 0; }
In D4768#202978, @vladislavbelov wrote:You can set both MIN_THREADS and MAX_THREADS to zero and it will work perfectly fine.
That's not different with your patch.
In D4768#202976, @vladislavbelov wrote:That's a not good fix, as it implicitly relies on MIN_THREADS non being zero.
Why do we need an extra function GetDefaultNumberOfWorkers? Evaluating the number of workers is done in the constructor.
The problem would be solved by: Clamp<size_t>(std::thread::hardware_concurrency() - 1, MIN_THREADS, MAX_THREADS) -> Clamp<size_t>(std::thread::hardware_concurrency(), MIN_THREADS, MAX_THREADS) - 1. The the equation "Worker + main = Threads" would also make sens.
availableLocales is assigned only in the constructor. If LoadListOfAvailableLocales would be a free or static function availableLocales could be initialized in the constructor and be const
Aug 16 2022
In D4764#202871, @vladislavbelov wrote:icu::Locale is about 200 bytes, if there is no too much vector resizing then changes make sense.