diff options
Diffstat (limited to 'src/lane.cpp')
| -rw-r--r-- | src/lane.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lane.cpp b/src/lane.cpp index b23ff78..952b337 100644 --- a/src/lane.cpp +++ b/src/lane.cpp | |||
| @@ -775,6 +775,10 @@ static void lane_main(Lane* const lane_) | |||
| 775 | delete lane_; | 775 | delete lane_; |
| 776 | return; | 776 | return; |
| 777 | } | 777 | } |
| 778 | } else { | ||
| 779 | // some error occurred in lane_new and we don't have anything to do | ||
| 780 | lua_settop(_L, 0); // should already be the case, but I'm paranoid | ||
| 781 | kCancelError.pushKey(_L); // this is our return value, as if we were cancelled right from the start | ||
| 778 | } | 782 | } |
| 779 | 783 | ||
| 780 | // leave results (1..top) or error message + stack trace (1..2) on the stack - master will copy them | 784 | // leave results (1..top) or error message + stack trace (1..2) on the stack - master will copy them |
| @@ -872,6 +876,13 @@ Lane::Lane(Universe* const U_, lua_State* const L_, ErrorTraceLevel const errorT | |||
| 872 | , errorTraceLevel{ errorTraceLevel_ } | 876 | , errorTraceLevel{ errorTraceLevel_ } |
| 873 | { | 877 | { |
| 874 | STACK_CHECK_START_REL(S, 0); | 878 | STACK_CHECK_START_REL(S, 0); |
| 879 | |||
| 880 | // Store a pointer to ourselves in the lane's registry, for 'cancel_test()' (we do cancel tests at pending send/receive). | ||
| 881 | kLanePointerRegKey.setValue(S, | ||
| 882 | [lane = this](lua_State* L_) { lua_pushlightuserdata(L_, lane); } // S: | ||
| 883 | ); | ||
| 884 | STACK_CHECK(S, 0); | ||
| 885 | |||
| 875 | assert(errorTraceLevel == ErrorTraceLevel::Minimal || errorTraceLevel == ErrorTraceLevel::Basic || errorTraceLevel == ErrorTraceLevel::Extended); | 886 | assert(errorTraceLevel == ErrorTraceLevel::Minimal || errorTraceLevel == ErrorTraceLevel::Basic || errorTraceLevel == ErrorTraceLevel::Extended); |
| 876 | kExtendedStackTraceRegKey.setValue(S, [yes = errorTraceLevel == ErrorTraceLevel::Extended ? 1 : 0](lua_State* L_) { lua_pushboolean(L_, yes); }); | 887 | kExtendedStackTraceRegKey.setValue(S, [yes = errorTraceLevel == ErrorTraceLevel::Extended ? 1 : 0](lua_State* L_) { lua_pushboolean(L_, yes); }); |
| 877 | U->tracker.tracking_add(this); | 888 | U->tracker.tracking_add(this); |
| @@ -1228,6 +1239,21 @@ void Lane::securizeDebugName(lua_State* const L_) | |||
| 1228 | } | 1239 | } |
| 1229 | 1240 | ||
| 1230 | // ################################################################################################# | 1241 | // ################################################################################################# |
| 1242 | void Lane::signalReady(bool const canRun_) | ||
| 1243 | { | ||
| 1244 | if (!canRun_) { | ||
| 1245 | std::lock_guard _guard{ doneMutex }; | ||
| 1246 | // this will cause lane_main to skip actual running (because we are not Pending anymore) | ||
| 1247 | status.store(Lane::Running, std::memory_order_release); | ||
| 1248 | } | ||
| 1249 | #ifndef __PROSPERO__ | ||
| 1250 | ready.count_down(); | ||
| 1251 | #else // __PROSPERO__ | ||
| 1252 | ready.test_and_set(); | ||
| 1253 | #endif // __PROSPERO__ | ||
| 1254 | } | ||
| 1255 | |||
| 1256 | // ################################################################################################# | ||
| 1231 | 1257 | ||
| 1232 | void Lane::startThread(lua_State* const L_, int const priority_, NativePrioFlag native_) | 1258 | void Lane::startThread(lua_State* const L_, int const priority_, NativePrioFlag native_) |
| 1233 | { | 1259 | { |
