Add a switch to destroy runtime only on shutdown (#4482)

This commit is contained in:
Alexander Shabalin
2020-11-13 09:19:10 +03:00
committed by Stanislav Erokhin
parent 37ff2c338e
commit ee508efb23
18 changed files with 254 additions and 37 deletions
@@ -8,17 +8,26 @@
#include <cassert>
#include <thread>
constexpr int kInitialValue = 0;
constexpr int kNewValue = 1;
constexpr int kErrorValue = 2;
int main() {
std::thread main1([]() {
assert(testlib_symbols()->kotlin.root.readFromA() == 0);
testlib_symbols()->kotlin.root.writeToA(1);
assert(testlib_symbols()->kotlin.root.readFromA() == 1);
assert(testlib_symbols()->kotlin.root.tryReadFromA(kErrorValue) == kInitialValue);
testlib_symbols()->kotlin.root.writeToA(kNewValue);
assert(testlib_symbols()->kotlin.root.tryReadFromA(kErrorValue) == kNewValue);
});
main1.join();
std::thread main2([]() {
#if defined(IS_LEGACY)
// Globals were reinitialized.
assert(testlib_symbols()->kotlin.root.readFromA() == 0);
assert(testlib_symbols()->kotlin.root.tryReadFromA(kErrorValue) == kInitialValue);
#else
// Globals are not accessible.
assert(testlib_symbols()->kotlin.root.tryReadFromA(kErrorValue) == kErrorValue);
#endif
});
main2.join();