1
0
forked from 0ad/0ad
Commit Graph

9 Commits

Author SHA1 Message Date
f5b416c63b Don't execute the task when no Future awaits it anymore
Summary:
Most of the times the callback stores a reference to a variable in scope
where the `Future` is in. When the scope is left the reference get's
dangling. `CancelOrWait` is called in multiple places (mostly
destructors) to ensure the callback isn't executed anymore.
This patch deduplicates thous calls to `CancelOrWait`.

Refs: #5874

Comments by: @Stan, @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D5208
This was SVN commit r28128.
2024-06-25 19:03:01 +00:00
ffc4a56b9f Revert non-ASCII characters from source and configuration files introduced in 157c6af18e.
Fixes #6846

Differential Revision: https://code.wildfiregames.com/D5185
This was SVN commit r27965.
2023-12-03 00:30:12 +00:00
6ee136dd11 Split Receiver from SharedState
The Function is not restricted to std::function anymore. Move only
function become possible.

Differential Revision: https://code.wildfiregames.com/D4840
This was SVN commit r27962.
2023-11-30 09:20:35 +00:00
1e3f11ff6d Disallow conversion in Future return
Differential Revision: https://code.wildfiregames.com/D4812
This was SVN commit r27947.
2023-11-19 21:04:40 +00:00
bb
157c6af18e Make the space in 0 A.D. non-breaking throughout the codebase.
Avoid cases of filenames
Update years in terms and other legal(ish) documents
Don't update years in license headers, since change is not meaningful

Will add linter rule in seperate commit

Happy recompiling everyone!

Original Patch By: Nescio
Comment By: Gallaecio
Differential Revision: D2620
This was SVN commit r27786.
2023-07-27 20:54:46 +00:00
a333c8f355 Use Future::CancelOrWait in pathfinder Deinit
If the pathfinding tasks are running, they might reference now-deleted
variables. CancelOrWait prevents this.
Remove `Future::Cancel()` altogether as that was its only use and the
functions seems dangerous.

Introduced with 0ebc08b13c

Patch by: phosit
Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D4831
This was SVN commit r27310.
2022-12-28 11:34:04 +00:00
92153b0afb Replace SharedStateResult with std::optional
std::optional was not usable when our Future class was introduced, but
it is now, so we can replace SharedStateResult with it, reducing custom
code.

Note that Apple Clang has some incompatibilites with part of the
optional interface, but it isn't used here.

Patch by: phosit
Comments by: vladislavbelov
Accepted by: wraitii
Differential Revision: https://code.wildfiregames.com/D4803
This was SVN commit r27309.
2022-12-28 10:54:41 +00:00
aaa95dc00b Minor cleanup in Future and TaskManager
- Remove redundant std::move() calls
- default ctor/dtor in place of empty {}

Patch by: jprahman
Comments by; phosit

Accepted by: vladislavbelov
Differential Revision: https://code.wildfiregames.com/D4675
This was SVN commit r26916.
2022-06-02 12:59:25 +00:00
1b35d36daa Implement a global task manager using a pool of worker threads
Tasks are simple callables (e.g. lambdas), and can be pushed with 2
priority levels. Pushing a task returns a future.
Futures can be waited on, can return results, and can be cancelled
deterministically. Futures can also not be waited on.

This gives 'hardware concurrency - 1' threads to maximize CPU usage in a
work-stealing workflow.

Reviewed by: vladislavbelov
Refs #5874

Differential Revision: https://code.wildfiregames.com/D3848
This was SVN commit r25656.
2021-06-03 14:48:38 +00:00