1、Rust 异步 Runtime 的兼容层施继成 DatenLordIntroduce whats rust async runtime#Rust async runtimeAnalyze the reason of runtime isolation#Async runtime binding#Compatible layer1Create a wheel used everywhere Table of Contents23#Rust async runtime1Light-weight taskLanguage and compiler define tasksHow to run it?
2、When to run it?How does it deal with the I/O?Rust async runtimeRuntime responsibilities Invoke waiting tasks and halt tasks Get notifications from the OS Schedule tasks across threads if its multi-thread modelRust async runtimeAvailable Runtimes Tokio Async-std Smol MonoioRust async runtime#Async ru
3、ntime binding2Which runtime to choose?More adoptersRich eco-systemRich out-of-box featuresMaybe better performanceClean interfaceAsync runtime bindingEco system binding Panic“not currently running on the Tokioruntime”Hyper-fast and safe HTTP for tokio Surf-HTTP client framework for async-stdAsync ru
4、ntime bindingBarriers on runtime switch Switch all I/O related data structures Switch all async macros Switch all functions Scan everywhere We have to provide an abstraction to avoid thatAsync runtime bindingBuild libs for all runtimes Impossible You dont know how many runtimes there Provide a wrapp
5、er for runtimes Easy switch with rust features and conditional compilationAsync runtime binding#Compatible layer3Insight of compatible layerRust lang and compiler syntax and task typeAsync compatible layer I/O and task managementCompatible layerCompatible LayerCompare runtimesTokioAsync-stdSimilar c
6、omponent structuresCompatible layerCompare runtimesTokioAsync-stdAlmost the same APIsCompatible layerMain components in async runtimes Macros Data structures and associate functions Raw functionsCompatible layerMacro wrapperConditional comp