I refactored Filesystem::listdir_recursive to support removing the path
prefix from the returned files list. There are no current calls that
make use of the prefix parameter, so I converted it into a boolean.
Current usages will use the new default parameter and will not see any
changed behavior.
RemoteServer and PluginManager side would need complete redesign to be
data race free and concurrent. But as that would be unlikely to be
required from DFHack I decided simpler solution that is fixing data
ownership to a thread and all ServerConnection share a single lock which
allows access to PluginManager and Core.
The initial run_dfhack_init loads shared state information that is used
by EventManager when state changes. There is a small risk that
EventManager can handle events while run_dfhack_init is still running.
Alter World to use Persistence instead of storing data in historical figures.
Fake historical figures will be converted to the new format when a world is loaded.
Added plugin_save and plugin_load functions to the plugin API.
Made the weird int7/int28 code that was in the old persistence API slightly safer.
Also modified Core/Console a bit to get this to actually produce output on
Travis (DFHACK_DISABLE_CONSOLE now allows console output, just not input)
Squashed merge from lethosor/tests
_exit seems to run dll unloading code which calls static destructors.
Standrd requires std::_Exit not to call destructors which makes using it
attractive in case MSVC actually follows the standard.
The old CoreSuspender requires processing from Core::Update to allow
commands execute. But that causes issues if Core::Shutdown wants
quarentee cleanup order with std:🧵:join. Fixing shutdown ordering
adds too many branches to already fairly complex code.
I decided to try to refactor CoreSuspender to use simpler locking
locking using a std::recusive_muted as primary synchronization
primitive.
To help control when Core::Update unlocks the primary mutex there is
std::contition_variable_any and std::atomic<size_t> queue lenght
counter.
The last state variable is std::atomic<std:🧵:id> that is used to
keep track of owner thread for Core::IsSuspended query.
This should be merged only just after a release to make sure that it
gets maximum testing in develop branch before next release.
Fixes#1066
There is a minor chance that console or init thread would access already
freed memory when core is shutting down and cleaning up state. To avoid
any danger of having random bugs caused by the potential data race I
decided to make sure the shutdown code waits for the thread to exit
first.
Windows change is completely untested. It is purely based on msdn
documentation.
I noticed that tthread is missing some c++11 features that make thread
handling code a bit easier. To be able to use those features I decided
to convert Core.cpp to use equivalent standard classes.
This patch has no functional changes.