Commit Graph

57 Commits (jgrpp)

Author SHA1 Message Date
Jonathan G Rennison ba79f7b2ba Merge branch 'master' into jgrpp
# Conflicts:
#	src/base_station_base.h
#	src/newgrf_roadstop.cpp
#	src/newgrf_station.cpp
#	src/object_gui.cpp
#	src/saveload/settings_sl.cpp
#	src/saveload/station_sl.cpp
#	src/settings.cpp
#	src/settings_internal.h
#	src/timer/timer_game_calendar.cpp
2 months ago
Loïc Guilloux b53d79b1d2
Codechange: Don't use NOT_REACHED() when catching unhandled thread exceptions (#12199) 3 months ago
Jonathan G Rennison 7f6b1d6b94 Merge branch 'master' into jgrpp
# Conflicts:
#	src/company_cmd.cpp
#	src/company_func.h
#	src/core/overflowsafe_type.hpp
#	src/engine.cpp
#	src/music/midifile.cpp
#	src/network/network_command.cpp
#	src/newgrf_debug_gui.cpp
#	src/newgrf_roadstop.h
#	src/newgrf_spritegroup.cpp
#	src/os/macosx/crashlog_osx.cpp
#	src/os/unix/crashlog_unix.cpp
#	src/pathfinder/yapf/yapf_common.hpp
#	src/road_gui.cpp
#	src/saveload/engine_sl.cpp
#	src/script/api/script_depotlist.cpp
#	src/script/api/script_roadtypelist.cpp
#	src/settings_gui.cpp
#	src/settings_type.h
#	src/strings.cpp
#	src/table/settings/game_settings.ini
5 months ago
Rubidium e3f49ee7a0 Codechange: coding style fixes 5 months ago
Jonathan G Rennison ea3b991f72 MinGW: Remove direct mingw-std-threads includes 5 months ago
Jonathan G Rennison ed1b842ad3 Merge branch 'master' into jgrpp
# Conflicts:
#	src/console.cpp
#	src/console_func.h
#	src/network/network_server.cpp
#	src/os/unix/unix.cpp
#	src/spritecache.cpp
#	src/viewport.cpp
8 months ago
Rubidium 69d5b9d326 Cleanup: unused NO_THREADS #ifdefs 11 months ago
Jonathan G Rennison 6bc3481931 Fix MinGW compilation issues 3 years ago
Patric Stout 0550ca0854 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.

(cherry picked from commit b45c006ab9)
3 years ago
Jonathan G Rennison 87948d8029 Thread: Adjust checks for whether current thread is the game thread 3 years ago
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.
3 years ago
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 3 years ago
Jonathan G Rennison 63ddf7f587 Crashlog: Update thread/lock handling to match GameLoop changes 3 years ago
Jonathan G Rennison 5e14b54a0c Merge branch 'master' into jgrpp 3 years ago
Michael Lutz 13011e00c6 Fix #8860: [Win32] Crashlog window wasn't reliably shown for crashes not on the main thread. 3 years ago
Jonathan G Rennison f53697ce76 Windows: Call SetThreadStackGuarantee for all threads, not just main thread 3 years ago
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.
3 years ago
Jonathan G Rennison cbdd9f84d8 Merge branch 'master' into jgrpp
# Conflicts:
#	src/console_gui.cpp
#	src/lang/korean.txt
#	src/video/sdl2_v.cpp
#	src/video/sdl2_v.h
#	src/window.cpp
#	src/window_gui.h
5 years ago
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 5 years ago
Jonathan G Rennison 601f3aaef4 Fix race condition causing crashes/undefined behaviour on thread init on windows/MinGW 5 years ago
Jonathan G Rennison 674732cd68 Merge: Codechange: Use null pointer literal instead of the NULL macro 5 years ago
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 5 years ago
Jonathan G Rennison f887b12be2 Add 3rd party mingw-std-threads headers to fix MinGW compilation 5 years ago
Jonathan G Rennison d5ee9d34da Merge branch 'cpp-11' into crashlog_improvements
# Conflicts:
#	Makefile.src.in
#	projects/determineversion.vbs
#	source.list
#	src/crashlog.cpp
#	src/misc.cpp
#	src/os/unix/crashlog_unix.cpp
#	src/os/windows/crashlog_win.cpp
#	src/rev.h
#	src/thread/thread.h
#	src/thread/thread_morphos.cpp
#	src/thread/thread_none.cpp
#	src/thread/thread_os2.cpp
#	src/thread/thread_pthread.cpp
#	src/thread/thread_win32.cpp
5 years ago
Michael Lutz 967b27a2c1 Codechange: C++11 STL has a function for getting the number of CPU cores. 5 years ago
Michael Lutz ae748166d0 Codechange: Use platform independent C++11 function for sleeping on a thread. 5 years ago
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.
5 years ago
rubidium 07d2af338e (svn r17339) -Codechange: move thread related files to their own directory (like done for video, music, sound, etc) 15 years ago
rubidium 533e3da493 (svn r17339) -Codechange: move thread related files to their own directory (like done for video, music, sound, etc) 15 years ago
rubidium 7fbc33dae1 (svn r17248) -Fix: add GPL license notice where appropriate 15 years ago
rubidium 99d46e0ad7 (svn r17248) -Fix: add GPL license notice where appropriate 15 years ago
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. 16 years ago
rubidium 82e98c2188 (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. 16 years ago
rubidium bb77071749 (svn r15158) -Cleanup: remove some unused/unneeded cruft from the thread generalisation. 16 years ago
rubidium 202aeb8306 (svn r15158) -Cleanup: remove some unused/unneeded cruft from the thread generalisation. 16 years ago
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) 16 years ago
truebrain 546d1b7580 (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) 16 years ago
rubidium e43d050730 (svn r13417) -Fix (r12945, r13413): freeing the ThreadObjects in a manner that hopefully doesn't cause crashes. 16 years ago
rubidium f80d8dbe0c (svn r13417) -Fix (r12945, r13413): freeing the ThreadObjects in a manner that hopefully doesn't cause crashes. 16 years ago
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) 16 years ago
truebrain e767b4f778 (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) 16 years ago
rubidium 96d7f87cc9 (svn r13411) -Codechange: remove the return value from the thread procs because it is never used. 16 years ago
rubidium 4657ae97fc (svn r13411) -Codechange: remove the return value from the thread procs because it is never used. 16 years ago
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. 16 years ago
rubidium 1ce0b03bf0 (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. 16 years ago
rubidium 12188e7a5d (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable. 16 years ago
rubidium d022d4af3d (svn r12706) -Merge: the thread rewrite from NoAI. The rewrite makes the threading we have better extendable. 16 years ago
rubidium 5d3f058b65 (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var. 17 years ago
rubidium 59d33d0f7c (svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var. 17 years ago
belugas f81217bcf4 (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done 17 years ago