-
Notifications
You must be signed in to change notification settings - Fork 912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: move scheduler code around #4549
base: dev
Are you sure you want to change the base?
Conversation
Size difference with the dev branch: Binary size differenceflash ram before after diff before after diff 286072 286024 -48 -0.02% 17812 17812 0 0.00% tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/webserver/ 296572 296548 -24 -0.01% 13788 13788 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal -stack-size 8kb ./examples/net/http-get/ 287068 287044 -24 -0.01% 18212 18212 0 0.00% tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/mqttclient/paho/ 83072 83056 -16 -0.02% 6588 6588 0 0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/lora/lorawan/atcmd/ 119296 119280 -16 -0.01% 7848 7848 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 -stack-size 8kb ./examples/net/tcpclient/ 245452 245436 -16 -0.01% 10488 10488 0 0.00% tinygo build -size short -o ./build/test.hex -target=nano-rp2040 -stack-size 8kb ./examples/net/websocket/dial/ 111508 111492 -16 -0.01% 7772 7772 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-mkrwifi1010 -stack-size 8kb ./examples/net/tlsclient/ 13732 13724 -8 -0.06% 4940 4940 0 0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-wl55jc ./examples/sx126x/lora_rxtx/ 16844 16844 0 0.00% 4324 4324 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/adafruit4650 61344 61344 0 0.00% 6196 6196 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adt7410/main.go 9548 9548 0 0.00% 4756 4756 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/adxl345/main.go 13548 13548 0 0.00% 6796 6796 0 0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/amg88xx 8660 8660 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/main.go 9776 9776 0 0.00% 4768 4768 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/apa102/itsybitsy-m0/main.go 8348 8348 0 0.00% 2320 2320 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/at24cx/main.go 8104 8104 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bh1750/main.go 7412 7412 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/blinkm/main.go 70472 70472 0 0.00% 3660 3660 0 0.00% tinygo build -size short -o ./build/test.hex -target=pinetime ./examples/bma42x/main.go 63868 63868 0 0.00% 6196 6196 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmi160/main.go 27388 27388 0 0.00% 4788 4788 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp180/main.go 63920 63920 0 0.00% 6228 6228 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/bmp280/main.go 12180 12180 0 0.00% 4820 4820 0 0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bmp388/main.go 8164 8164 0 0.00% 3348 3348 0 0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/sram/main.go 22152 22152 0 0.00% 3544 3544 0 0.00% tinygo build -size short -o ./build/test.hex -target=bluepill ./examples/ds1307/time/main.go 69616 69616 0 0.00% 6376 6376 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/ds3231/main.go 4600 4600 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/easystepper/main.go 69168 69168 0 0.00% 6976 6976 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/flash/console/spi 7192 7192 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/gc9a01/main.go 67556 67556 0 0.00% 6368 6368 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/i2c/main.go 68092 68092 0 0.00% 6504 6504 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/gps/uart/main.go 7852 7852 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/hcsr04/main.go 5812 5812 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/customchar/main.go 5764 5764 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hd44780/text/main.go 10508 10508 0 0.00% 4756 4756 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/hd44780i2c/main.go 16128 16128 0 0.00% 2360 2360 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/hub75/main.go 10136 10136 0 0.00% 6916 6916 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/basic 10624 10624 0 0.00% 4868 4868 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/basic 29488 29488 0 0.00% 38076 38076 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/pyportal_boing 10156 10156 0 0.00% 6924 6924 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/scroll 10712 10712 0 0.00% 4876 4876 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/ili9341/scroll 263540 263540 0 0.00% 46760 46760 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/ili9341/slideshow 11712 11712 0 0.00% 4788 4788 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis3dh/main.go 26108 26108 0 0.00% 2328 2328 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/lsm303agr/main.go 12428 12428 0 0.00% 4796 4796 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/lsm6ds3/main.go 10724 10724 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mag3110/main.go 9896 9896 0 0.00% 4780 4780 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017/main.go 10348 10348 0 0.00% 4788 4788 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp23017-multiple/main.go 9760 9760 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp3008/main.go 68512 68512 0 0.00% 6196 6196 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mcp2515/main.go 27244 27244 0 0.00% 3648 3648 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/microbitmatrix/main.go 26956 26956 0 0.00% 5696 5696 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit-v2 ./examples/microbitmatrix/main.go 8220 8220 0 0.00% 4756 4756 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mma8653/main.go 8128 8128 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/mpu6050/main.go 75792 75792 0 0.00% 7480 7480 0 0.00% tinygo build -size short -o ./build/test.hex -target=p1am-100 ./examples/p1am/main.go 12232 12232 0 0.00% 3352 3352 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/pca9685/main.go 6208 6208 0 0.00% 3288 3288 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setbuffer/main.go 5240 5240 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/pcd8544/setpixel/main.go 10516 10516 0 0.00% 3328 3328 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/seesaw 2825 2825 0 0.00% 558 558 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino ./examples/servo 13748 13748 0 0.00% 3400 3400 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/sgp30 8064 8064 0 0.00% 6796 6796 0 0.00% tinygo build -size short -o ./build/test.hex -target=pybadge ./examples/shifter/main.go 57324 57324 0 0.00% 3692 3692 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht3x/main.go 57380 57380 0 0.00% 3700 3700 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/sht4x/main.go 57288 57288 0 0.00% 3692 3692 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/shtc3/main.go 6668 6668 0 0.00% 2288 2288 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1306/i2c_128x32/main.go 6120 6120 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1306/spi_128x64/main.go 5824 5824 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ssd1331/main.go 6764 6764 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7735/main.go 6676 6676 0 0.00% 2280 2280 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/st7789/main.go 16948 16948 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/thermistor/main.go 10048 10048 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/tm1637/main.go 10848 10848 0 0.00% 3340 3340 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/touch/capacitive 9504 9504 0 0.00% 6788 6788 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/fourwire/main.go 12572 12572 0 0.00% 6984 6984 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/touch/resistive/pyportal_touchpaint/main.go 14960 14960 0 0.00% 4756 4756 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl53l1x/main.go 13440 13440 0 0.00% 4756 4756 0 0.00% tinygo build -size short -o ./build/test.hex -target=itsybitsy-m0 ./examples/vl6180x/main.go 6468 6468 0 0.00% 2320 2320 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13/main.go 6156 6156 0 0.00% 2312 2312 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd2in13x/main.go 6380 6380 0 0.00% 2320 2320 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/waveshare-epd/epd4in2/main.go 26432 26432 0 0.00% 16732 16732 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/waveshare-epd/epd2in66b/main.go 6828 6828 0 0.00% 4788 4788 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/ws2812 5744 5744 0 0.00% 9538 9538 0 0.00% tinygo build -size short -o ./build/test.bin -target=m5stamp-c3 ./examples/ws2812 1581 1581 0 0.00% 598 598 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino ./examples/ws2812 1056 1056 0 0.00% 180 180 0 0.00% tinygo build -size short -o ./build/test.hex -target=digispark ./examples/ws2812 31832 31832 0 0.00% 4788 4788 0 0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/bme280/main.go 16420 16420 0 0.00% 4732 4732 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/microphone/main.go 11060 11060 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/buzzer/main.go 12768 12768 0 0.00% 4788 4788 0 0.00% tinygo build -size short -o ./build/test.hex -target=trinket-m0 ./examples/veml6070/main.go 6732 6732 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/simple/main.go 8644 8644 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l293x/speed/main.go 6700 6700 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/simple/main.go 9256 9256 0 0.00% 4756 4756 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/l9110x/speed/main.go 7320 7320 0 0.00% 3320 3320 0 0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-f103rb ./examples/shiftregister/main.go 6992 6992 0 0.00% 2268 2268 0 0.00% tinygo build -size short -o ./build/test.hex -target=hifive1b ./examples/ssd1351/main.go 12984 12984 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-express ./examples/lis2mdl/main.go 8860 8860 0 0.00% 4764 4764 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/max72xx/main.go 77204 77204 0 0.00% 6344 6344 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/dht/main.go 36512 36512 0 0.00% 3988 3988 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/pcf8523/ 71224 71224 0 0.00% 6344 6344 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/alarm/ 7256 7256 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/clkout/ 70760 70760 0 0.00% 6340 6340 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/time/ 71192 71192 0 0.00% 6352 6352 0 0.00% tinygo build -size short -o ./build/test.hex -target=xiao ./examples/pcf8563/timer/ 12164 12164 0 0.00% 3304 3304 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/qmi8658c/main.go 10788 10788 0 0.00% 3288 3288 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-rp2040 ./examples/pcf8591/ 8724 8724 0 0.00% 4756 4756 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina260/main.go 13176 13176 0 0.00% 4788 4788 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m0 ./examples/ina219/main.go 9312 9312 0 0.00% 5260 5260 0 0.00% tinygo build -size short -o ./build/test.hex -target=nucleo-l432kc ./examples/aht20/main.go 61432 61432 0 0.00% 8232 8232 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/i2csoft/adt7410/ 10280 10280 0 0.00% 6796 6796 0 0.00% tinygo build -size short -o ./build/test.elf -target=wioterminal ./examples/axp192/m5stack-core2-blinky/ 9008 9008 0 0.00% 3276 3276 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/xpt2046/main.go 31336 31336 0 0.00% 4548 4548 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/ssd1289/main.go 11236 11236 0 0.00% 4252 4252 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/irremote/main.go 11932 11932 0 0.00% 3324 3324 0 0.00% tinygo build -size short -o ./build/test.hex -target=badger2040 ./examples/uc8151/main.go 10408 10408 0 0.00% 3356 3356 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/scd4x/main.go 8532 8532 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=circuitplay-express ./examples/makeybutton/main.go 9644 9644 0 0.00% 4772 4772 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ds18b20/main.go 15896 15896 0 0.00% 4880 4880 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/as560x/main.go 9868 9868 0 0.00% 3296 3296 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu6886/main.go 7788 7788 0 0.00% 4748 4748 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ttp229/main.go 62212 62212 0 0.00% 3788 3788 0 0.00% tinygo build -size short -o ./build/test.hex -target=microbit ./examples/ndir/main_ndir.go 65196 65196 0 0.00% 6260 6260 0 0.00% tinygo build -size short -o ./build/test.hex -target=arduino-nano33 ./examples/ndir/main_ndir.go 9296 9296 0 0.00% 3288 3288 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mpu9150/main.go 11376 11376 0 0.00% 3324 3324 0 0.00% tinygo build -size short -o ./build/test.hex -target=macropad-rp2040 ./examples/sh1106/macropad_spi 8436 8436 0 0.00% 3760 3760 0 0.00% tinygo build -size short -o ./build/test.hex -target=macropad-rp2040 ./examples/encoders/quadrature-interrupt 85868 85868 0 0.00% 5140 5140 0 0.00% tinygo build -size short -o ./build/test.hex -target=challenger-rp2040 ./examples/net/ntpclient/ 103040 103048 8 0.01% 9816 9816 0 0.00% tinygo build -size short -o ./build/test.hex -target=metro-m4-airlift -stack-size 8kb ./examples/net/socket/ 338372 338380 8 0.00% 15396 15396 0 0.00% tinygo build -size short -o ./build/test.hex -target=matrixportal-m4 -stack-size 8kb ./examples/net/webstatic/ 154136 154144 8 0.01% 6540 6540 0 0.00% tinygo build -size short -o ./build/test.hex -target=nano-rp2040 -stack-size 8kb ./examples/net/mqttclient/natiu/ 116984 116992 8 0.01% 13132 13132 0 0.00% tinygo build -size short -o ./build/test.hex -target=wioterminal -stack-size 8kb ./examples/net/webclient/ 62332 62348 16 0.03% 5952 5952 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/is31fl3731/main.go 66752 66768 16 0.02% 4816 4816 0 0.00% tinygo build -size short -o ./build/test.hex -target=pico ./examples/ndir/main_ndir.go 65720 65736 16 0.02% 4784 4784 0 0.00% tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mcp9808/main.go 65548 65572 24 0.04% 9012 9012 0 0.00% tinygo build -size short -o ./build/test.hex -target=pyportal ./examples/flash/console/qspi 72636 72660 24 0.03% 10748 10748 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-m4 ./examples/sdcard/console/ 11784 11812 28 0.24% 6580 6580 0 0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/apds9960/proximity/main.go 14708 14736 28 0.19% 6580 6580 0 0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/hts221/main.go 14052 14080 28 0.20% 6580 6580 0 0.00% tinygo build -size short -o ./build/test.hex -target=nano-33-ble ./examples/lps22hb/main.go 10504 10532 28 0.27% 4540 4540 0 0.00% tinygo build -size short -o ./build/test.hex -target=circuitplay-bluefruit ./examples/tone 24684 24712 28 0.11% 13892 13892 0 0.00% tinygo build -size short -o ./build/test.hex -target=feather-nrf52840-sense ./examples/waveshare-epd/epd1in54/main.go 5327990 5328090 100 0.00% 811790 811790 0 0.00% |
4915b43
to
a966d9a
Compare
Note: this PR conflicts with some changes I'd like to make to the sync package to make it thread-safe, so waiting until this one is merged before I submit those other PRs (see #4559). |
825d379
to
074a493
Compare
This moves all scheduler code into a separate file that is only compiled when there's a scheduler in use (the tasks or asyncify scheduler, which are both cooperative). The main goal of this change is to make it easier to add a new "scheduler" based on OS threads. It also fixes a few subtle issues with `-gc=none`: - Gosched() panicked. This is now fixed to just return immediately (the only logical thing to do when there's only one goroutine). - Timers aren't supported without a scheduler, but the relevant code was still present and would happily add a timer to the queue. It just never ran. So now it exits with a runtime error, similar to any blocking operation.
074a493
to
8c13718
Compare
Rebased to resolve merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by review.
@@ -36,7 +36,8 @@ func procUnpin() { | |||
|
|||
func waitForEvents() { | |||
mask := riscv.DisableInterrupts() | |||
if !runqueue.Empty() { | |||
runqueue := schedulerRunQueue() | |||
if !(runqueue != nil && runqueue.Empty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: runqueue == nil || !runqueue.Empty()
is clearer to me, but I understand why you write it like this.
Nittier: if rq := schedulerRunQueue(); rq == nil || !rq.Empty() {
// This function is not actually used, it is only called when hasScheduler | ||
// is true. So we can just return nil here. | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: panic("unreachable")
like scheduler
below?
} | ||
|
||
func scheduler(returnAtDeadlock bool) { | ||
// This *should* be unreachable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: unhelpful comment.
This moves all scheduler code into a separate file that is only compiled when there's a scheduler in use (the tasks or asyncify scheduler, which are both cooperative). The main goal of this change is to make it easier to add a new "scheduler" based on OS threads.
It also fixes a few subtle issues with
-gc=none
:runtime.Gosched()
panicked. This is now fixed to just return immediately (the only logical thing to do when there's only one goroutine).Other than that, this really just moves code around.