| 142 | } |
| 143 | |
| 144 | void CoroutineContext::suspend() FL_NOEXCEPT { |
| 145 | auto& platform = ICoroutinePlatform::instance(); |
| 146 | |
| 147 | // ISR guard |
| 148 | if (platform.inInterruptContext()) { |
| 149 | return; |
| 150 | } |
| 151 | |
| 152 | CoroutineContext* self = globals().current; |
| 153 | if (!self) { |
| 154 | return; // Not inside a coroutine |
| 155 | } |
| 156 | |
| 157 | void* runner = get_runner_ctx(); |
| 158 | if (!runner) { |
| 159 | return; |
| 160 | } |
| 161 | |
| 162 | // Check stack health before switching — catch overflow early |
| 163 | if (!platform.checkStackHealth(self->mPlatformCtx)) { |
| 164 | FL_WARN("FATAL: Stack overflow detected in coroutine"); |
| 165 | while (true) {} // Halt — memory is already corrupted |
| 166 | } |
| 167 | |
| 168 | // Switch back to runner |
| 169 | platform.contextSwitch(self->mPlatformCtx, runner); |
| 170 | |
| 171 | // Resumed — we're back in the coroutine |
| 172 | } |
| 173 | |
| 174 | //============================================================================= |
| 175 | // CoroutineRunner Implementation |
nothing calls this directly
no test coverage detected