@@ -298,62 +298,16 @@ int co_main(int argc, char **argv)
298
298
<summary>DEBUG run output</summary>
299
299
300
300
<pre>
301
- Thread #7f11090f11c0 running coroutine id: 1 () status: x cycles: x
302
301
Start of main Goroutine
303
- Back at coroutine scheduling
304
- Thread #7f11090f11c0 running coroutine id: 2 () status: x cycles: x
305
302
0 ==> John
306
- Back at coroutine scheduling
307
- Thread #7f11090f11c0 running coroutine id: 3 () status: x cycles: x
308
303
0 ==> Mary
309
- Back at coroutine scheduling
310
- Thread #7f11090f11c0 running coroutine id: 4 () status: x cycles: x
311
- Back at coroutine scheduling
312
- Thread #7f11090f11c0 running coroutine id: 4 (coroutine_wait) status: x cycles: x
313
- Back at coroutine scheduling
314
- Thread #7f11090f11c0 running coroutine id: 2 () status: x cycles: x
304
+ 1 ==> Mary - Thrd #c080080, cid: 4 (coroutine_wait) Active/Running cycles: 18
315
305
1 ==> John
316
- Back at coroutine scheduling
317
- Thread #7f11090f11c0 running coroutine id: 3 () status: x cycles: x
318
- 1 ==> Mary
319
- Back at coroutine scheduling
320
- Thread #7f11090f11c0 running coroutine id: 4 (coroutine_wait) status: x cycles: x
321
- Back at coroutine scheduling
322
- Thread #7f11090f11c0 running coroutine id: 4 (coroutine_wait) status: x cycles: x
323
- Back at coroutine scheduling
324
- Thread #7f11090f11c0 running coroutine id: 2 () status: x cycles: x
325
- 2 ==> John
326
- Back at coroutine scheduling
327
- Thread #7f11090f11c0 running coroutine id: 3 () status: x cycles: x
306
+ 2 ==> John - Thrd #c080080, cid: 4 (coroutine_wait) Active/Running cycles: 99
328
307
2 ==> Mary
329
- Back at coroutine scheduling
330
- Thread #7f11090f11c0 running coroutine id: 4 (coroutine_wait) status: x cycles: x
331
- Back at coroutine scheduling
332
- Thread #7f11090f11c0 running coroutine id: 4 (coroutine_wait) status: x cycles: x
333
- Back at coroutine scheduling
334
- Thread #7f11090f11c0 running coroutine id: 2 () status: x cycles: x
335
- Back at coroutine scheduling
336
- Thread #7f11090f11c0 running coroutine id: 3 () status: x cycles: x
337
- Back at coroutine scheduling
338
- Thread #7f11090f11c0 running coroutine id: 4 (coroutine_wait) status: x cycles: x
339
- Back at coroutine scheduling
340
- Thread #7f11090f11c0 running coroutine id: 4 (coroutine_wait) status: x cycles: x
341
- Back at coroutine scheduling
342
- Thread #7f11090f11c0 running coroutine id: 4 (coroutine_wait) status: x cycles: x
343
- Back at coroutine scheduling
344
- Thread #7f11090f11c0 running coroutine id: 4 (coroutine_wait) status: x cycles: x
345
- Back at coroutine scheduling
346
- ...
347
- ...
348
- ...
349
- ...
350
- Thread #7f6ac8aa11c0 running coroutine id: 4 (coroutine_wait) status: x cycles: x
351
- Back at coroutine scheduling
352
- Thread #7f6ac8aa11c0 running coroutine id: 4 (coroutine_wait) status: x cycles: x
353
- Back at coroutine scheduling
354
- Thread #7f6ac8aa11c0 running coroutine id: 1 (co_main) status: x cycles: x
308
+ - Thrd #c080080, cid: 4 (coroutine_wait) Active/Running cycles: 8404
355
309
End of main Goroutine
356
- Back at coroutine scheduling
310
+
357
311
Coroutine scheduler exited
358
312
</pre>
359
313
</details>
@@ -427,19 +381,14 @@ int co_main(int argc, char **argv) {
427
381
<summary>DEBUG run output</summary>
428
382
429
383
<pre>
430
- Thread #7f87171711c0 running coroutine id: 1 () status: x cycles: x
431
384
processed
432
- r:0x7fffb878dca0
433
- Back at coroutine scheduling
434
- Thread #7f87171711c0 running coroutine id: 2 () status: x cycles: x
385
+ r:000002592E480080
435
386
processed
436
- s:0x7fffb878dca0 *
437
- => s:0x7fffb878dca0
387
+ s:000002592E480080 *
388
+ => s:000002592E480080
438
389
No receiver! Send Operation Blocked
439
- Back at coroutine scheduling
440
- Thread #7f87171711c0 running coroutine id: 1 (co_main) status: x cycles: x
441
390
Received. Send Operation Successful
442
- Back at coroutine scheduling
391
+
443
392
Coroutine scheduler exited
444
393
</pre>
445
394
</details>
@@ -532,129 +481,6 @@ int co_main(int argc, char **argv) {
532
481
</tr>
533
482
</table>
534
483
535
- <details>
536
- <summary>DEBUG run output</summary>
537
-
538
- <pre>
539
- Thread #7f2dadbb11c0 running coroutine id: 1 () status: x cycles: x
540
- Back at coroutine scheduling
541
- Thread #7f2dadbb11c0 running coroutine id: 2 () status: x cycles: x
542
- processed
543
- r:0x7fffc1f35ca0
544
- Back at coroutine scheduling
545
- Thread #7f2dadbb11c0 running coroutine id: 1 (co_main) status: x cycles: x
546
- processed
547
- s:0x7fffc1f35ca0*
548
- => s:0x7fffc1f35ca0
549
- Back at coroutine scheduling
550
- Thread #7f2dadbb11c0 running coroutine id: 2 () status: x cycles: x
551
- 0
552
- processed
553
- r:0x7fffc1f35ca0
554
- Back at coroutine scheduling
555
- Thread #7f2dadbb11c0 running coroutine id: 1 (co_main) status: x cycles: x
556
- processed
557
- s:0x7fffc1f35ca0*
558
- => s:0x7fffc1f35ca0
559
- Back at coroutine scheduling
560
- Thread #7f2dadbb11c0 running coroutine id: 2 () status: x cycles: x
561
- 1
562
- processed
563
- r:0x7fffc1f35ca0
564
- Back at coroutine scheduling
565
- Thread #7f2dadbb11c0 running coroutine id: 1 (co_main) status: x cycles: x
566
- processed
567
- s:0x7fffc1f35ca0*
568
- => s:0x7fffc1f35ca0
569
- Back at coroutine scheduling
570
- Thread #7f2dadbb11c0 running coroutine id: 2 () status: x cycles: x
571
- 1
572
- processed
573
- r:0x7fffc1f35ca0
574
- Back at coroutine scheduling
575
- Thread #7f2dadbb11c0 running coroutine id: 1 (co_main) status: x cycles: x
576
- processed
577
- s:0x7fffc1f35ca0*
578
- => s:0x7fffc1f35ca0
579
- Back at coroutine scheduling
580
- Thread #7f2dadbb11c0 running coroutine id: 2 () status: x cycles: x
581
- 2
582
- processed
583
- r:0x7fffc1f35ca0
584
- Back at coroutine scheduling
585
- Thread #7f2dadbb11c0 running coroutine id: 1 (co_main) status: x cycles: x
586
- processed
587
- s:0x7fffc1f35ca0*
588
- => s:0x7fffc1f35ca0
589
- Back at coroutine scheduling
590
- Thread #7f2dadbb11c0 running coroutine id: 2 () status: x cycles: x
591
- 3
592
- processed
593
- r:0x7fffc1f35ca0
594
- Back at coroutine scheduling
595
- Thread #7f2dadbb11c0 running coroutine id: 1 (co_main) status: x cycles: x
596
- processed
597
- s:0x7fffc1f35ca0*
598
- => s:0x7fffc1f35ca0
599
- Back at coroutine scheduling
600
- Thread #7f2dadbb11c0 running coroutine id: 2 () status: x cycles: x
601
- 5
602
- processed
603
- r:0x7fffc1f35ca0
604
- Back at coroutine scheduling
605
- Thread #7f2dadbb11c0 running coroutine id: 1 (co_main) status: x cycles: x
606
- processed
607
- s:0x7fffc1f35ca0*
608
- => s:0x7fffc1f35ca0
609
- Back at coroutine scheduling
610
- Thread #7f2dadbb11c0 running coroutine id: 2 () status: x cycles: x
611
- 8
612
- processed
613
- r:0x7fffc1f35ca0
614
- Back at coroutine scheduling
615
- Thread #7f2dadbb11c0 running coroutine id: 1 (co_main) status: x cycles: x
616
- processed
617
- s:0x7fffc1f35ca0*
618
- => s:0x7fffc1f35ca0
619
- Back at coroutine scheduling
620
- Thread #7f2dadbb11c0 running coroutine id: 2 () status: x cycles: x
621
- 13
622
- processed
623
- r:0x7fffc1f35ca0
624
- Back at coroutine scheduling
625
- Thread #7f2dadbb11c0 running coroutine id: 1 (co_main) status: x cycles: x
626
- processed
627
- s:0x7fffc1f35ca0*
628
- => s:0x7fffc1f35ca0
629
- Back at coroutine scheduling
630
- Thread #7f2dadbb11c0 running coroutine id: 2 () status: x cycles: x
631
- 21
632
- processed
633
- r:0x7fffc1f35ca0
634
- Back at coroutine scheduling
635
- Thread #7f2dadbb11c0 running coroutine id: 1 (co_main) status: x cycles: x
636
- processed
637
- s:0x7fffc1f35ca0*
638
- => s:0x7fffc1f35ca0
639
- Back at coroutine scheduling
640
- Thread #7f2dadbb11c0 running coroutine id: 2 () status: x cycles: x
641
- 34
642
- processed
643
- s:0x7fffc1f35f10
644
- Back at coroutine scheduling
645
- Thread #7f2dadbb11c0 running coroutine id: 1 (co_main) status: x cycles: x
646
- processed
647
- r:0x7fffc1f35f10*
648
- => r:0x7fffc1f35f10
649
- quit
650
- Back at coroutine scheduling
651
- Thread #7f2dadbb11c0 running coroutine id: 2 () status: x cycles: x
652
- Back at coroutine scheduling
653
- Coroutine scheduler exited
654
-
655
- </pre>
656
- </details>
657
-
658
484
Original **Go** example from <https://www.developer.com/languages/go-error-handling-with-panic-recovery-and-defer/>
659
485
660
486
<table>
@@ -733,15 +559,10 @@ int co_main(int argc, char **argv) {
733
559
<summary>DEBUG run output</summary>
734
560
735
561
<pre>
736
- Thread #7fd29c4011c0 running coroutine id: 1 () status: x cycles: x
737
- Back at coroutine scheduling
738
- Thread #7fd29c4011c0 running coroutine id: 2 () status: x cycles: x
739
- panic occurred: sig_ill
740
- Back at coroutine scheduling
741
- Thread #7fd29c4011c0 running coroutine id: 1 (co_main) status: x cycles: x
562
+ panic occurred: divide_by_zero
742
563
Although panicked. We recovered. We call mul() func
743
564
mul func result: 50
744
- Back at coroutine scheduling
565
+
745
566
Coroutine scheduler exited
746
567
</pre>
747
568
</details>
@@ -836,64 +657,31 @@ int co_main(int argc, char **argv)
836
657
<summary>DEBUG run output</summary>
837
658
838
659
<pre>
839
- Thread #7f48f6c211c0 running coroutine id: 1 () status: x cycles: x
840
- Back at coroutine scheduling
841
- Thread #7f48f6c211c0 running coroutine id: 2 () status: x cycles: x
660
+ Worker 1 starting
661
+ - Thrd #a38e0080, cid: 2 () Active/Running cycles: 1
842
662
Worker 2 starting
843
- Back at coroutine scheduling
844
- Thread #7f48f6c211c0 running coroutine id: 3 () status: x cycles: x
663
+ - Thrd #a38e0080, cid: 3 () Active/Running cycles: 1
845
664
Worker 3 starting
846
- Back at coroutine scheduling
847
- Thread #7f48f6c211c0 running coroutine id: 4 () status: x cycles: x
665
+ - Thrd #a38e0080, cid: 4 () Active/Running cycles: 1
848
666
Worker 4 starting
849
- Back at coroutine scheduling
850
- Thread #7f48f6c211c0 running coroutine id: 5 () status: x cycles: x
667
+ - Thrd #a38e0080, cid: 5 () Active/Running cycles: 1
851
668
Worker 5 starting
852
- Back at coroutine scheduling
853
- Thread #7f48f6c211c0 running coroutine id: 6 () status: x cycles: x
854
- Worker 6 starting
855
- Back at coroutine scheduling
856
- Thread #7f48f6c211c0 running coroutine id: 1 (co_main) status: x cycles: x
857
- Back at coroutine scheduling
858
- Thread #7f48f6c211c0 running coroutine id: 7 () status: x cycles: x
859
- Back at coroutine scheduling
860
- Thread #7f48f6c211c0 running coroutine id: 6 () status: x cycles: x
861
- Worker 6 done
862
- Back at coroutine scheduling
863
- Thread #7f48f6c211c0 running coroutine id: 1 (co_main) status: x cycles: x
864
- Back at coroutine scheduling
865
- Thread #7f48f6c211c0 running coroutine id: 7 (coroutine_wait) status: x cycles: x
866
- Back at coroutine scheduling
867
- Thread #7f48f6c211c0 running coroutine id: 5 () status: x cycles: x
868
- Worker 5 done
869
- Back at coroutine scheduling
870
- Thread #7f48f6c211c0 running coroutine id: 1 (co_main) status: x cycles: x
871
- Back at coroutine scheduling
872
- Thread #7f48f6c211c0 running coroutine id: 7 (coroutine_wait) status: x cycles: x
873
- Back at coroutine scheduling
874
- Thread #7f48f6c211c0 running coroutine id: 4 () status: x cycles: x
875
- Worker 4 done
876
- Back at coroutine scheduling
877
- Thread #7f48f6c211c0 running coroutine id: 1 (co_main) status: x cycles: x
878
- Back at coroutine scheduling
879
- Thread #7f48f6c211c0 running coroutine id: 7 (coroutine_wait) status: x cycles: x
880
- Back at coroutine scheduling
881
- Thread #7f48f6c211c0 running coroutine id: 3 () status: x cycles: x
882
- Worker 3 done
883
- Back at coroutine scheduling
884
- Thread #7f48f6c211c0 running coroutine id: 1 (co_main) status: x cycles: x
885
- Back at coroutine scheduling
886
- Thread #7f48f6c211c0 running coroutine id: 7 (coroutine_wait) status: x cycles: x
887
- Back at coroutine scheduling
888
- Thread #7f48f6c211c0 running coroutine id: 2 () status: x cycles: x
889
- Worker 2 done
890
- Back at coroutine scheduling
891
- Thread #7f48f6c211c0 running coroutine id: 1 (co_main) status: x cycles: x
669
+ - Thrd #a38e0080, cid: 6 () Active/Running cycles: 1
670
+ Worker 5 done - Thrd #a38e0080, cid: 1 (co_main) Active/Running cycles: 2
671
+ - Thrd #a38e0080, cid: 6 () Active/Running cycles: 2
672
+ Worker 2 done - Thrd #a38e0080, cid: 1 (co_main) Active/Running cycles: 3
673
+ - Thrd #a38e0080, cid: 3 () Active/Running cycles: 2
674
+ Worker 3 done - Thrd #a38e0080, cid: 1 (co_main) Active/Running cycles: 4
675
+ - Thrd #a38e0080, cid: 4 () Active/Running cycles: 2
676
+ Worker 1 done - Thrd #a38e0080, cid: 1 (co_main) Active/Running cycles: 5
677
+ - Thrd #a38e0080, cid: 2 () Active/Running cycles: 2
678
+ Worker 4 done - Thrd #a38e0080, cid: 1 (co_main) Active/Running cycles: 6
679
+ - Thrd #a38e0080, cid: 5 () Active/Running cycles: 2
892
680
893
681
Worker # 4 returned: 32
894
682
895
683
Worker # 3 returned: hello world
896
- Back at coroutine scheduling
684
+
897
685
Coroutine scheduler exited
898
686
</pre>
899
687
</details>
@@ -981,37 +769,17 @@ int co_main(int argc, char **argv) {
981
769
<summary>DEBUG run output</summary>
982
770
983
771
<pre>
984
- Thread #7fc61b3d11c0 running coroutine id: 1 () status: x cycles: x
985
- promise id(706099430) created in thread #7fc61b3d11c0
986
- thread #7fc61b3d11c0 created thread #7fc61b2b0700 with status(0) future id(706099430)
772
+ promise id(16038) created in thread #18d80080
773
+ thread #18d80080 created thread #18d80130 with status(0) future id(16038)
987
774
checking...
988
- Back at coroutine scheduling
989
- Thread #7fc61b3d11c0 running coroutine id: 1 (co_main) status: x cycles: x
990
- Back at coroutine scheduling
991
- Thread #7fc61b3d11c0 running coroutine id: 1 (co_main) status: x cycles: x
992
- Back at coroutine scheduling
993
- Thread #7fc61b3d11c0 running coroutine id: 1 (co_main) status: x cycles: x
994
- Back at coroutine scheduling
995
- ...
996
- ...
997
- ...
998
- ...
999
- Thread #7fc61b3d11c0 running coroutine id: 1 (co_main) status: x cycles: x
1000
- Back at coroutine scheduling
1001
- Thread #7fc61b3d11c0 running coroutine id: 1 (co_main) status: x cycles: x
1002
- Back at coroutine scheduling
1003
- Thread #7fc61b3d11c0 running coroutine id: 1 (co_main) status: x cycles: x
1004
- Back at coroutine scheduling
1005
- promise id(706099430) set LOCK in thread #7fc61b2b0700
1006
- promise id(706099430) set UNLOCK in thread #7fc61b2b0700
1007
- Thread #7fc61b3d11c0 running coroutine id: 1 (co_main) status: x cycles: x
1008
- Back at coroutine scheduling
1009
- Thread #7fc61b3d11c0 running coroutine id: 1 (co_main) status: x cycles: x
1010
-
1011
- 194232491 promise id(706099430) get LOCK in thread #7fc61b3d11c0
1012
- promise id(706099430) get UNLOCK in thread #7fc61b3d11c0
1013
- is prime!
1014
- Back at coroutine scheduling
775
+ promise id(16038) set LOCK in thread #18d80130
776
+ promise id(16038) set UNLOCK in thread #18d80130
777
+ - Thrd #18d80080, cid: 1 (co_main) Active/Running cycles: 34289
778
+ 194232491
779
+ promise id(16038) get LOCK in thread #18d80080
780
+ promise id(16038) get UNLOCK in thread #18d80080
781
+ is prime.
782
+
1015
783
Coroutine scheduler exited
1016
784
</pre>
1017
785
</details>
0 commit comments