Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <wheels/test/framework.hpp>
- // https://gitlab.com/Lipovsky/tinyfibers
- #include <tf/sched/spawn.hpp>
- #include <tf/sched/yield.hpp>
- #include <tf/sync/mutex.hpp>
- #include <fmt/core.h>
- using tf::Mutex;
- using tf::Spawn;
- using tf::Yield;
- void OneFiberDeadLock() {
- Mutex mutex;
- auto fiber = [&] {
- mutex.Lock();
- fmt::println("I am in Fiber #2");
- mutex.Unlock();
- };
- mutex.Lock();
- Spawn(fiber).Join();
- mutex.Unlock();
- // We do not expect to reach this line
- FAIL_TEST("No deadlock =(");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement