| 282 | //============================================================================= |
| 283 | |
| 284 | TaskCoroutinePtr TaskCoroutineTeensy::create( |
| 285 | fl::string name, |
| 286 | TaskFunction function, |
| 287 | size_t stack_size, |
| 288 | u8 /*priority*/) FL_NOEXCEPT { |
| 289 | auto* ctx = CoroutineContext::create(fl::move(function), stack_size); |
| 290 | if (!ctx) { |
| 291 | FL_WARN("TaskCoroutineTeensy: Failed to create context for '" << name << "'"); |
| 292 | return nullptr; |
| 293 | } |
| 294 | |
| 295 | TaskCoroutinePtr task(new TaskCoroutineTeensy()) FL_NOEXCEPT; // ok bare allocation |
| 296 | auto* impl = static_cast<TaskCoroutineTeensy*>(task.get()); |
| 297 | impl->mName = fl::move(name); |
| 298 | impl->mContext.reset(ctx); |
| 299 | |
| 300 | // Register with the global runner |
| 301 | CoroutineRunner::instance().enqueue(ctx); |
| 302 | |
| 303 | return task; |
| 304 | } |
| 305 | |
| 306 | TaskCoroutineTeensy::~TaskCoroutineTeensy() { |
| 307 | stop(); |