* @warning If this blocks forever, it might be because of the Thread, but it could also be because another task is blocking the CPU. */
| 224 | * @warning If this blocks forever, it might be because of the Thread, but it could also be because another task is blocking the CPU. |
| 225 | */ |
| 226 | bool join(TickType_t timeout = kernel::MAX_TICKS, TickType_t pollInterval = 10) { |
| 227 | assert(getCurrent() != this); |
| 228 | |
| 229 | TickType_t start_ticks = kernel::getTicks(); |
| 230 | while (getTaskHandle()) { |
| 231 | kernel::delayTicks(pollInterval); |
| 232 | if (kernel::getTicks() - start_ticks > timeout) { |
| 233 | return false; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | return true; |
| 238 | } |
| 239 | |
| 240 | TaskHandle_t getTaskHandle() const { return taskHandle; } |
| 241 |