test5.d 323 B

1234567891011121314151617181920212223242526272829303132
  1. import std.stdio;
  2. import core.thread : Fiber;
  3. void foo(){
  4. writeln("Hello");
  5. Fiber.yield();
  6. writeln("World");
  7. }
  8. void test5_spawner(){
  9. auto f = new Fiber(&foo);
  10. //f.call(); // Hello
  11. //f.call(); // World
  12. while(f.state != Fiber.State.TERM){
  13. f.call();
  14. }
  15. }
  16. /*
  17. ./vtest2
  18. hello here!
  19. Hello
  20. World
  21. */