Advanced · Module 10 · Lesson 6 of 6
Project: A Movable Task Type
Combine an id with an erased callable into a move-only task, transfer it through a queue, and run it exactly once.
By the end you can
- Build a move-only task holding an id plus an erased callable
- Transfer tasks through a queue without copying
- Explain why single ownership prevents double execution
Builds on Member Pointers and std::function Callables.
01 · A question first
A pool holds one hundred units of work from different call sites. Each unit carries its own data and runs once. Copying would duplicate side effects, sharing would double run. What type lets the queue take ownership and then hand it to exactly one worker?
Make a guess before you read on.
02 · The idea
Members only
Unlock the full lesson
This lesson is part of the membership. Join to read it in full, along with every other premium deep dive.
What's inside
- Start with the problem
- How the idea works
- Why it is correct
- What it costs
- Testing single ownership
- Pitfalls and variations
- Complete solution
- Where it is used
03 · Practice
Asked in interviews
Something wrong with this lesson? Report a problem