Commit Graph

27 Commits

Author SHA1 Message Date
Loïc Guilloux b53d79b1d2
Codechange: Don't use NOT_REACHED() when catching unhandled thread exceptions (#12199) 2024-03-02 00:07:43 +01:00
Rubidium e3f49ee7a0 Codechange: coding style fixes 2024-01-04 16:23:54 +01:00
Rubidium 69d5b9d326 Cleanup: unused NO_THREADS #ifdefs 2023-06-28 19:07:10 +02:00
Patric Stout b45c006ab9
Fix: on startup, NewGRF scan could case race-condition (#9382)
Creating a thread was not thread-safe. The irony.

The video-driver has a function GameLoopPause() which first checks
if the thread is the game-thread or not. For this it needs access
to this->game_thread. This variable is set in StartNewThread().

However, due to timing, it is well possible GameLoopPause() is
called from the thread well before this->game_thread is assigned.

And so we have a race-condition!

Simply solve this by preventing a thread to start till we are
done with our bookkeeping.
2021-06-17 20:10:40 +02:00
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 2021-06-13 12:45:45 +02:00
Michael Lutz 13011e00c6 Fix #8860: [Win32] Crashlog window wasn't reliably shown for crashes not on the main thread. 2021-03-13 22:09:05 +01:00
Patric Stout 970fedd78c Add: make modal windows update more smooth
Basically, modal windows had their own thread-locking for what
drawing was possible. This is a bit nonsense now we have a
game-thread. And it makes much more sense to do things like
NewGRFScan and GenerateWorld in the game-thread, and not in a
thread next to the game-thread.

This commit changes that: it removes the threads for NewGRFScan
and GenerateWorld, and just runs the code in the game-thread.
On regular intervals it allows the draw-thread to do a tick,
which gives a much smoother look and feel.

It does slow down NewGRFScan and GenerateWorld ever so slightly
as it spends more time on drawing. But the slowdown is not
measureable on my machines (with 700+ NewGRFs / 4kx4k map and
a Debug build).

Running without a game-thread means NewGRFScan and GenerateWorld
are now blocking.
2021-03-10 13:41:18 +01:00
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 2019-04-10 23:22:20 +02:00
Michael Lutz 967b27a2c1 Codechange: C++11 STL has a function for getting the number of CPU cores. 2019-04-06 11:27:39 +02:00
Michael Lutz ae748166d0 Codechange: Use platform independent C++11 function for sleeping on a thread. 2019-04-06 11:27:39 +02:00
Michael Lutz 05bc2ed7cb Codechange: Replace custom thread code with C++11 thread objects.
We assume a conforming C++11 compiler environment that has a valid <thread>-header.
Failure to run a real thread is handled gracefully.
2019-04-06 11:27:39 +02:00
rubidium 07d2af338e (svn r17339) -Codechange: move thread related files to their own directory (like done for video, music, sound, etc) 2009-09-01 10:07:22 +00:00
rubidium 7fbc33dae1 (svn r17248) -Fix: add GPL license notice where appropriate 2009-08-21 20:21:05 +00:00
rubidium 6a3aaef486 (svn r15159) -Fix: move the UDP queries that resolve a hostname into threads so they don't freeze OpenTTD when for example the network connection got severed. Thanks to glx for writing the mutex implementation for Windows. 2009-01-20 03:44:43 +00:00
rubidium bb77071749 (svn r15158) -Cleanup: remove some unused/unneeded cruft from the thread generalisation. 2009-01-20 03:12:46 +00:00
truebrain 53ca48efe2 (svn r15006) -Codechange: throw a real instance of a class, instead of '0' (which can also be a throw from within a thread for what ever reason) 2009-01-12 14:31:49 +00:00
rubidium e43d050730 (svn r13417) -Fix (r12945, r13413): freeing the ThreadObjects in a manner that hopefully doesn't cause crashes. 2008-06-08 15:27:57 +00:00
truebrain b95042b05c (svn r13412) -Add: OTTDThreadTerminateFunc, for all thread systems, which is called when a thread is terminated. Now GenWorld- and SaveLoad-thread cleanup theirselves correctly, while Fibers don't (as that causes access-violations) 2008-06-08 12:06:27 +00:00
rubidium 96d7f87cc9 (svn r13411) -Codechange: remove the return value from the thread procs because it is never used. 2008-06-08 10:51:36 +00:00
rubidium d03994098b (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description. 2008-05-06 15:11:33 +00:00
rubidium 12188e7a5d (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable. 2008-04-14 19:54:33 +00:00
rubidium 5d3f058b65 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var. 2007-07-24 17:01:23 +00:00
belugas f81217bcf4 (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done 2007-04-04 03:21:14 +00:00
rubidium 24c4d5b06d (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {}; 2007-03-07 12:11:48 +00:00
rubidium 36bb92ae24 (svn r9050) -Codechange: Foo(void) -> Foo() 2007-03-07 11:47:46 +00:00
rubidium 66bbf336c6 (svn r7759) -Merge: makefile rewrite. This merge features:
- A proper ./configure, so everything needs to be configured only once, not for every make.
 - Usage of makedepend when available. This greatly reduces the time needed for generating the dependencies.
 - A generator for all project files. There is a single file with sources, which is used to generate Makefiles and the project files for MSVC.
 - Proper support for OSX universal binaries.
 - Object files for non-MSVC compiles are also placed in separate directories, making is faster to switch between debug and release compiles and it does not touch the directory with the source files.
 - Functionality to make a bundle of all needed files for for example a nightly or distribution of a binary with all needed GRFs and language files.

Note: as this merge moves almost all files, it is recommended to make a backup of your working copy before updating your working copy.
2007-01-02 19:19:48 +00:00
Renamed from thread.h (Browse further)