Advertisement
den4ik2003

Untitled

Aug 31st, 2023
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <wheels/test/framework.hpp>
  2.  
  3. // https://gitlab.com/Lipovsky/tinyfibers
  4. #include <tf/sched/spawn.hpp>
  5. #include <tf/sched/yield.hpp>
  6. #include <tf/sync/mutex.hpp>
  7.  
  8. #include <fmt/core.h>
  9.  
  10. using tf::Mutex;
  11. using tf::Spawn;
  12. using tf::Yield;
  13.  
  14. void OneFiberDeadLock() {
  15. Mutex mutex;
  16.  
  17. auto fiber = [&] {
  18. mutex.Lock();
  19. fmt::println("I am in Fiber #2");
  20. mutex.Unlock();
  21. };
  22.  
  23. mutex.Lock();
  24.  
  25. Spawn(fiber).Join();
  26.  
  27. mutex.Unlock();
  28.  
  29. // We do not expect to reach this line
  30. FAIL_TEST("No deadlock =(");
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement