Merge branch 'master' into tyler_elastic_threadpool
commit
ea2da1f4a4
@ -0,0 +1 @@
|
||||
book
|
@ -0,0 +1,6 @@
|
||||
[book]
|
||||
authors = ["The async-std maintainers"]
|
||||
language = "en"
|
||||
multilingual = false
|
||||
src = "src"
|
||||
title = "Async programming in Rust with async-std"
|
@ -0,0 +1,23 @@
|
||||
# Summary
|
||||
|
||||
- [Overview](./overview.md)
|
||||
- [`async-std`](./overview/async-std.md)
|
||||
- [`std::future` and `futures-rs`](./overview/std-and-library-futures.md)
|
||||
- [Stability guarantees](./overview/stability-guarantees.md)
|
||||
- [Async concepts using async-std](./concepts.md)
|
||||
- [Futures](./concepts/futures.md)
|
||||
- [Tasks](./concepts/tasks.md)
|
||||
- [Async read/write](./concepts/async-read-write.md)
|
||||
- [Streams and Channels](./concepts/streams.md)
|
||||
- [Tutorials](./tutorials/index.md)
|
||||
- [Integrating std::thread](./tutorials/integrating-std-thread.md)
|
||||
- [Async Patterns](./patterns.md)
|
||||
- [Fork/Join](./patterns/fork-join.md)
|
||||
- [Accepting requests](./patterns/accepting-concurrent-requests.md)
|
||||
- [Proper Shutdown](./patterns/proper-shutdown.md)
|
||||
- [Background Tasks](./patterns/background-tasks.md)
|
||||
- [Testing](./patterns/testing.md)
|
||||
- [Collected Small Patterns](./patterns/small-patterns.md)
|
||||
- [Security practices](./security/index.md)
|
||||
- [Security disclosures and policy](./security/policy.md)
|
||||
- [Glossary](./glossary.md)
|
@ -0,0 +1,15 @@
|
||||
# Async concepts using async-std
|
||||
|
||||
[Rust Futures][futures] have the reputation of being hard. We don't think this is the case. They are, in our opinion, one of the easiest concurrency concepts around and have an intuitive explanation.
|
||||
|
||||
However, there are good reasons for that perception. Futures have three concepts at their base that seem to be a constant source of confusion: deferred computation, asynchronicity and independence of execution strategy.
|
||||
|
||||
These concepts are not hard, but something many people are not used to. This base confusion is amplified by many implementations oriented on details and hard to understand. Most explanations of these implementations also target advanced users. We both try to provide easy to understand primitives and approachable overviews of the concepts.
|
||||
|
||||
Futures are a concept that abstracts over how code is run. By themselves, they do nothing. This is a weird concept in an imperative language, where usually one thing happens after the other - right now.
|
||||
|
||||
So how do Futures run? You decide! Futures do nothing without the piece of code _executing_ them. This part is called an _executor_. An _executor_ decides _when_ and _how_ to execute your futures. The `async-std::task` module provides you with and interface to such an executor.
|
||||
|
||||
Let's start with a little bit of motivation, though.
|
||||
|
||||
[futures]: https://en.wikipedia.org/wiki/Futures_and_promises
|
@ -0,0 +1 @@
|
||||
# Async read/write
|
@ -0,0 +1 @@
|
||||
# Streams
|
@ -0,0 +1,7 @@
|
||||
# Glossary
|
||||
|
||||
### blocking
|
||||
|
||||
"blocked" generally refers to conditions that keep a task from doing its work. For example, it might need data to be sent by a client before continuing. When tasks becomes blocked, usually, other tasks are scheduled.
|
||||
|
||||
Sometimes you hear that you should never call "blocking functions" in an async context. What this refers to is functions that block the current thread and do not yield control back. This keeps the executor from using this thread to schedule another task.
|
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="645"
|
||||
height="157"
|
||||
fill="none"
|
||||
version="1.1"
|
||||
id="svg13"
|
||||
sodipodi:docname="horizontal_color.svg"
|
||||
inkscape:export-filename="/home/anxhelo/works/async-std/PNG/horizontal_color.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:version="0.92.4 (unknown)">
|
||||
<metadata
|
||||
id="metadata17">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1366"
|
||||
inkscape:window-height="717"
|
||||
id="namedview15"
|
||||
showgrid="false"
|
||||
inkscape:zoom="0.53937447"
|
||||
inkscape:cx="277.57355"
|
||||
inkscape:cy="86.621231"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg13" />
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M28.82 17.165a3.54 3.54 0 0 1 4.096-.657l11.462 5.786c5.67-3.453 11.9-6.08 18.52-7.71l4-12.15A3.54 3.54 0 0 1 70.259 0H86.74a3.54 3.54 0 0 1 3.361 2.432l3.943 11.98c6.77 1.59 13.14 4.215 18.936 7.702l11.104-5.605a3.54 3.54 0 0 1 4.096.657l11.655 11.655a3.54 3.54 0 0 1 .656 4.096l-5.462 10.82c3.72 5.917 6.532 12.464 8.24 19.443l11.3 3.72A3.54 3.54 0 0 1 157 70.259V86.74a3.54 3.54 0 0 1-2.432 3.361l-11.045 3.635a65.94 65.94 0 0 1-8.216 20.075l5.185 10.272a3.54 3.54 0 0 1-.656 4.096l-11.655 11.655a3.54 3.54 0 0 1-4.096.657l-10.216-5.157a65.96 65.96 0 0 1-20.178 8.328l-3.59 10.905A3.54 3.54 0 0 1 86.741 157H70.26a3.54 3.54 0 0 1-3.361-2.432l-3.644-11.072c-7.1-1.708-13.754-4.558-19.76-8.344l-10.58 5.34a3.54 3.54 0 0 1-4.096-.657L17.165 128.18a3.54 3.54 0 0 1-.657-4.096l5.482-10.86a65.92 65.92 0 0 1-7.803-19.252l-11.756-3.87A3.54 3.54 0 0 1 0 86.741V70.26a3.54 3.54 0 0 1 2.432-3.361l12.014-3.954c1.656-6.664 4.32-12.93 7.82-18.626L16.51 32.915a3.54 3.54 0 0 1 .657-4.096L28.82 17.165zm15.275 100.06c3.73 3.698 8.102 6.356 12.755 7.976-9.23-12.134-8.305-29.524 2.776-40.604s28.47-12.005 40.604-2.776a33.91 33.91 0 0 0-8.081-12.86c-13.3-13.3-34.86-13.3-48.16 0-13.264 13.263-13.3 34.746-.106 48.053l.106.106.106.105zm48.09-.143a15.04 15.04 0 0 0-21.303-21.227 15.04 15.04 0 0 0 21.227 21.303l.076-.076zm11.22-59.38c17.3 17.3 19.265 44.13 5.892 63.595a50.17 50.17 0 0 0 4.741-4.178c19.343-19.344 19.343-50.706 0-70.05s-50.706-19.344-70.05 0a50 50 0 0 0-4.178 4.74c19.464-13.373 46.294-11.41 63.595 5.892z"
|
||||
fill="url(#A)"
|
||||
id="path2" />
|
||||
<path
|
||||
d="M215.985 113.357c-4.846 0-8.9-1.293-12.127-3.88S199 103.12 199 98.167c0-3.792.914-6.73 2.743-8.812 1.85-2.104 4.24-3.628 7.17-4.57 2.953-.965 6.07-1.622 9.352-1.973 4.472-.482 7.678-.932 9.616-1.348 1.96-.416 2.94-1.48 2.94-3.2v-.197c0-2.477-.738-4.395-2.214-5.754s-3.602-2.038-6.377-2.038c-2.93 0-5.255.636-6.973 1.907-1.696 1.27-2.842 2.773-3.437 4.505l-11.17-1.578c1.322-4.603 3.9-8.078 7.733-10.423 3.855-2.345 8.448-3.518 13.78-3.518 2.423 0 4.846.285 7.27.855s4.638 1.512 6.642 2.828c2.027 1.315 3.646 3.1 4.858 5.327 1.234 2.236 1.85 5.02 1.85 8.352v33.8h-11.5v-6.94h-.397c-1.08 2.126-2.84 4-5.287 5.6-2.423 1.578-5.628 2.367-9.616 2.367zm3.106-8.746c3.613 0 6.477-1.03 8.592-3.1s3.172-4.493 3.172-7.3v-5.95c-.506.416-1.443.8-2.808 1.118-1.344.307-2.776.57-4.296.8l-3.867.56c-2.665.373-4.9 1.107-6.675 2.203-1.784 1.074-2.676 2.75-2.676 5.03 0 2.192.804 3.847 2.412 4.965s3.657 1.677 6.146 1.677zm75.84-29.427l-10.905 1.184c-.463-1.666-1.454-3.135-2.974-4.406-1.498-1.27-3.624-1.907-6.378-1.907-2.5 0-4.582.537-6.28 1.6-1.674 1.074-2.5 2.466-2.478 4.176a4.45 4.45 0 0 0 1.619 3.617c1.124.92 2.974 1.666 5.552 2.236l8.658 1.84c9.495 2.06 14.253 6.62 14.275 13.678 0 3.18-.925 5.984-2.776 8.417-1.85 2.412-4.406 4.297-7.666 5.656s-7.006 2.038-11.235 2.038c-6.235 0-11.236-1.304-15.003-3.912s-6.025-6.226-6.774-10.85l11.665-1.118c1.035 4.603 4.395 6.905 10.08 6.905 2.84 0 5.122-.57 6.84-1.7 1.74-1.16 2.6-2.608 2.6-4.34 0-2.828-2.28-4.746-6.84-5.754l-8.658-1.808c-4.868-1.008-8.47-2.707-10.805-5.096-2.336-2.4-3.492-5.458-3.47-9.14 0-3.113.86-5.8 2.577-8.1 1.72-2.302 4.12-4.077 7.204-5.326 3.084-1.27 6.664-1.907 10.74-1.907 5.948 0 10.63 1.27 14.044 3.814 3.437 2.52 5.563 5.918 6.378 10.193zM312.9 132c-1.74 0-3.26-.153-4.56-.46s-2.3-.603-2.974-.888l2.776-9.535c2.622.745 4.814.877 6.576.394 1.784-.482 3.238-2.115 4.362-4.9l1.2-3.222-18.406-51.555h12.7l11.698 38.14h.528l11.73-38.14h12.723l-20.488 57.08c-1.4 3.967-3.58 7.135-6.5 9.502-2.93 2.4-6.708 3.584-11.334 3.584zm58.562-49.254v29.592H359.5V61.835h11.433v8.582h.595c1.167-2.806 3.03-5.042 5.585-6.708 2.577-1.688 5.76-2.532 9.55-2.532 5.243 0 9.45 1.655 12.623 4.965 3.194 3.3 4.78 8 4.758 14.04v32.157h-11.962V82.023c0-3.376-.88-6.017-2.644-7.924-1.74-1.907-4.152-2.86-7.237-2.86-3.15 0-5.727 1.008-7.732 3.025-2.005 1.995-3.007 4.822-3.007 8.483zm66.883 30.578c-5.045 0-9.385-1.107-13.02-3.32s-6.433-5.282-8.393-9.206c-1.94-3.924-2.908-8.428-2.908-13.514 0-5.15 1-9.678 2.974-13.58 1.982-3.924 4.78-6.992 8.393-9.206 3.635-2.214 7.93-3.32 12.888-3.32 4.14 0 7.798.756 10.97 2.27 3.172 1.5 5.706 3.595 7.6 6.313s2.974 5.907 3.24 9.568h-11.434c-.463-2.433-1.564-4.46-3.305-6.083-1.718-1.644-4.02-2.466-6.906-2.466-3.68 0-6.653 1.447-8.922 4.34-2.247 2.87-3.37 6.86-3.37 11.968 0 5.15 1.113 9.195 3.338 12.133 2.247 2.937 5.232 4.406 8.955 4.406 2.622 0 4.847-.746 6.675-2.236 1.85-1.5 3.03-3.595 3.536-6.313H460.1c-.287 3.573-1.344 6.73-3.173 9.47s-4.318 4.888-7.468 6.445-6.85 2.334-11.103 2.334zm62.33-33.932V89.2H470.2v-9.798h30.467zm52.698-4.208l-10.904 1.184c-.463-1.666-1.454-3.135-2.974-4.406-1.498-1.27-3.624-1.907-6.378-1.907-2.5 0-4.582.537-6.28 1.6-1.674 1.074-2.5 2.466-2.478 4.176a4.45 4.45 0 0 0 1.619 3.617c1.124.92 2.974 1.666 5.552 2.236l8.658 1.84c9.494 2.06 14.253 6.62 14.275 13.678 0 3.18-.925 5.984-2.776 8.417-1.85 2.412-4.406 4.297-7.666 5.656s-7.006 2.038-11.236 2.038c-6.234 0-11.235-1.304-15.002-3.912s-6.025-6.226-6.774-10.85l11.665-1.118c1.035 4.603 4.395 6.905 10.078 6.905 2.842 0 5.122-.57 6.84-1.7 1.74-1.16 2.6-2.608 2.6-4.34 0-2.828-2.28-4.746-6.84-5.754l-8.658-1.808c-4.868-1.008-8.47-2.707-10.806-5.096-2.335-2.4-3.5-5.458-3.47-9.14 0-3.113.86-5.8 2.577-8.1 1.72-2.302 4.12-4.077 7.204-5.326 3.084-1.27 6.664-1.907 10.74-1.907 5.948 0 10.63 1.27 14.044 3.814 3.437 2.52 5.562 5.918 6.377 10.193zm36.3-13.35v9.206h-10.012v26.107c0 2.4.528 3.968 1.586 4.735 1.057.745 2.335 1.118 3.833 1.118.75 0 1.432-.055 2.05-.164l1.454-.296 2.016 9.305c-.64.22-1.553.46-2.743.723-1.168.263-2.6.416-4.296.46-4.494.132-8.272-.964-11.334-3.288-3.04-2.323-4.55-5.863-4.528-10.62V71.04h-7.203v-9.206h7.203v-12.1h11.963v12.1h10.012zm28.296 51.39c-3.987 0-7.556-1.02-10.706-3.058s-5.64-4.998-7.47-8.878-2.742-8.592-2.742-14.138c0-5.6.925-10.346 2.775-14.204 1.873-3.858 4.395-6.784 7.568-8.78s6.708-2.992 10.607-2.992c2.996 0 5.442.504 7.336 1.512 1.917.986 3.437 2.18 4.56 3.584 1.146 1.38 2.016 2.685 2.6 3.913h.496V45H645v67.338h-11.764v-7.957h-.727c-.617 1.227-1.5 2.532-2.677 3.913-1.167 1.36-2.7 2.52-4.626 3.485s-4.33 1.447-7.237 1.447zm3.338-9.766c3.8 0 6.752-1.5 8.823-4.504 2.07-3.025 3.106-6.98 3.106-11.87 0-4.9-1.024-8.823-3.073-11.738-2.05-2.937-5-4.406-8.856-4.406-3.988 0-6.995 1.512-9.022 4.537s-3.04 6.894-3.04 11.607c0 4.735 1.025 8.647 3.074 11.738s5.044 4.636 8.988 4.636z"
|
||||
fill="#623871"
|
||||
id="path4" />
|
||||
<defs
|
||||
id="defs11">
|
||||
<linearGradient
|
||||
id="A"
|
||||
x1="4.998"
|
||||
y1="5.29"
|
||||
x2="146.855"
|
||||
y2="147.953"
|
||||
gradientUnits="userSpaceOnUse">
|
||||
<stop
|
||||
stop-color="#a047bf"
|
||||
id="stop6" />
|
||||
<stop
|
||||
offset="1"
|
||||
stop-color="#ee7e40"
|
||||
id="stop8" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 8.1 KiB |
@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="469.01221"
|
||||
height="469.01218"
|
||||
version="1.1"
|
||||
id="svg13"
|
||||
sodipodi:docname="icon_color.svg"
|
||||
inkscape:export-filename="/home/anxhelo/works/async-std/PNG/icon_color.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96"
|
||||
style="fill:none"
|
||||
inkscape:version="0.92.4 (unknown)">
|
||||
<metadata
|
||||
id="metadata17">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1366"
|
||||
inkscape:window-height="717"
|
||||
id="namedview15"
|
||||
showgrid="false"
|
||||
inkscape:zoom="0.53937447"
|
||||
inkscape:cx="66.57329"
|
||||
inkscape:cy="291.22962"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg13"
|
||||
fit-margin-top="0"
|
||||
fit-margin-left="0"
|
||||
fit-margin-right="0"
|
||||
fit-margin-bottom="0" />
|
||||
<path
|
||||
d="M 86.095104,51.277669 A 10.575179,10.575179 0 0 1 98.331245,49.314986 L 132.57212,66.59973 C 149.51034,56.284449 168.12148,48.436707 187.89765,43.567346 L 199.84697,7.271181 A 10.575179,10.575179 0 0 1 209.88744,0 h 49.23435 a 10.575179,10.575179 0 0 1 10.04045,7.265207 l 11.77908,35.788319 c 20.22425,4.749868 39.25361,12.591632 56.56825,23.008483 l 33.17138,-16.744035 a 10.575179,10.575179 0 0 1 12.23615,1.962681 l 34.81743,34.817435 a 10.575179,10.575179 0 0 1 1.95969,12.236139 l -16.31686,32.323011 c 11.11293,17.67608 19.51331,37.23418 24.61569,58.08281 l 33.75691,11.11291 a 10.575179,10.575179 0 0 1 7.26225,10.03447 v 49.23431 a 10.575179,10.575179 0 0 1 -7.26524,10.04045 l -32.99516,10.85899 a 196.98511,196.98511 0 0 1 -24.54397,59.97083 l 15.48937,30.68594 a 10.575179,10.575179 0 0 1 -1.95969,12.23614 l -34.81743,34.81742 a 10.575179,10.575179 0 0 1 -12.23617,1.96269 l -30.51863,-15.40572 a 197.04486,197.04486 0 0 1 -60.27851,24.87856 l -10.72455,32.57692 a 10.575179,10.575179 0 0 1 -10.03747,7.26821 h -49.23434 a 10.575179,10.575179 0 0 1 -10.04045,-7.26522 l -10.88586,-33.07581 c -21.2101,-5.10234 -41.08784,-13.61629 -59.0298,-24.92634 L 98.328261,419.69717 A 10.575179,10.575179 0 0 1 86.092106,417.73451 L 51.277691,382.91708 A 10.575179,10.575179 0 0 1 49.314997,370.68091 L 65.691571,338.23844 A 196.92537,196.92537 0 0 1 42.381367,280.72618 L 7.262224,269.16518 A 10.575179,10.575179 0 0 1 0,259.12475 V 209.89041 A 10.575179,10.575179 0 0 1 7.265222,199.84998 L 43.15511,188.03803 C 48.102142,168.13041 56.060396,149.41175 66.5161,132.39586 L 49.320974,98.328257 A 10.575179,10.575179 0 0 1 51.283667,86.092115 Z M 131.7267,350.19076 c 11.14277,11.0472 24.20343,18.98754 38.10349,23.82703 -27.57312,-36.24836 -24.80983,-88.19816 8.29289,-121.2979 33.10268,-33.09971 85.04954,-35.863 121.29791,-8.29284 a 101.30066,101.30066 0 0 0 -24.14072,-38.41718 c -39.7316,-39.73161 -104.1386,-39.73161 -143.87021,0 -39.624078,39.62107 -39.731608,103.79807 -0.31666,143.55059 l 0.31666,0.31663 z m 143.66113,-0.42716 a 44.929576,44.929576 0 0 0 -63.63929,-63.41226 44.929576,44.929576 0 0 0 63.41226,63.6393 z m 33.51796,-177.38818 c 51.68097,51.68096 57.55107,131.83126 17.60139,189.9798 a 149.87478,149.87478 0 0 0 14.16297,-12.4811 c 57.78409,-57.78709 57.78409,-151.47599 0,-209.26307 -57.7841,-57.787083 -151.476,-57.787083 -209.26309,0 a 149.36693,149.36693 0 0 0 -12.48111,14.15999 c 58.14557,-39.94969 138.29588,-34.08554 189.97984,17.60139 z"
|
||||
id="path2"
|
||||
style="fill:url(#A);fill-rule:evenodd;stroke-width:2.98733878"
|
||||
inkscape:connector-curvature="0" />
|
||||
<defs
|
||||
id="defs11">
|
||||
<linearGradient
|
||||
id="A"
|
||||
x1="4.9980001"
|
||||
y1="5.29"
|
||||
x2="146.855"
|
||||
y2="147.953"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(2.9873387,0,0,2.9873387,4e-6,0)">
|
||||
<stop
|
||||
stop-color="#a047bf"
|
||||
id="stop6" />
|
||||
<stop
|
||||
offset="1"
|
||||
stop-color="#ee7e40"
|
||||
id="stop8" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 4.6 KiB |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 10 KiB |
@ -0,0 +1,10 @@
|
||||
# Overview
|
||||
|
||||
![async-std logo](./images/horizontal_color.svg)
|
||||
|
||||
`async-std` along with its [supporting libraries][organization] is a library making your life in async programming easier. It provides provide fundamental implementations for downstream libraries and applications alike. The name reflects the approach of this library: it is a closely modeled to the Rust main standard library as possible, replacing all components by async counterparts.
|
||||
|
||||
`async-std` provides an interface to all important primitives: filesystem operations, network operations and concurrency basics like timers. It also exposes an `task` in a model similar to the `thread` module found in the Rust standard lib. But it does not only include io primitives, but also `async/await` compatible versions of primitives like `Mutex`. You can read more about `async-std` in [the overview chapter][overview-std].
|
||||
|
||||
[organization]: https://github.com/async-std/async-std
|
||||
[overview-std]: overview/async-std/
|
@ -0,0 +1 @@
|
||||
# async-std
|
@ -0,0 +1,40 @@
|
||||
# Stability and SemVer
|
||||
|
||||
`async-std` follows https://semver.org/.
|
||||
|
||||
In short: we are versioning our software as `MAJOR.MINOR.PATCH`. We increase the:
|
||||
|
||||
* MAJOR version when there are incompatible API changes,
|
||||
* MINOR version when we introducece functionality in a backwards-compatible manner
|
||||
* PATCH version when we make backwards-compatible bug fixes
|
||||
|
||||
We will provide migration documentation between major versions.
|
||||
|
||||
## Future expectations
|
||||
|
||||
`async-std` uses its own implementations of the following concepts:
|
||||
|
||||
* `Read`
|
||||
* `Write`
|
||||
* `Seek`
|
||||
* `BufRead`
|
||||
* `Stream`
|
||||
|
||||
For integration with the ecosystem, all types implementing these traits also have an implementation of the corresponding interfaces in the `futures-rs` library.
|
||||
Please note that our SemVer guarantees don't extend to usage of those interfaces. We expect those to be conservatively updated and in lockstep.
|
||||
|
||||
## Minimum version policy
|
||||
|
||||
The current tentative policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if `async-std` 1.0 requires Rust 1.37.0, then `async-std` 1.0.z for all values of z will also require Rust 1.37.0 or newer. However, `async-std` 1.y for y > 0 may require a newer minimum version of Rust.
|
||||
|
||||
In general, this crate will be conservative with respect to the minimum supported version of Rust. With `async/await` being a new feature though, we will track changes in a measured pace initially.
|
||||
|
||||
## Security fixes
|
||||
|
||||
Security fixes will be applied to _all_ minor branches of this library in all _supported_ major revisions. This policy might change in the future, in which case we give at least _3 month_ of ahead notice.
|
||||
|
||||
## Credits
|
||||
|
||||
This policy is based on [burntsushis regex crate][regex-policy].
|
||||
|
||||
[regex-policy]: https://github.com/rust-lang/regex#minimum-rust-version-policy
|
@ -0,0 +1,5 @@
|
||||
# Patterns
|
||||
|
||||
This section documents small, useful patterns.
|
||||
|
||||
It is intended to be read at a glance, allowing you to get back when you have a problem.
|
@ -0,0 +1 @@
|
||||
# Accepting requests
|
@ -0,0 +1 @@
|
||||
# Async read/write
|
@ -0,0 +1 @@
|
||||
# Background Tasks
|
@ -0,0 +1 @@
|
||||
# Fork/Join
|
@ -0,0 +1 @@
|
||||
# Proper Shutdown
|
@ -0,0 +1,16 @@
|
||||
# Small Patterns
|
||||
|
||||
A collection of small, useful patterns.
|
||||
|
||||
## Splitting streams
|
||||
|
||||
`async-std` doesn't provide a `split()` method on `io` handles. Instead, splitting a stream into a read and write half can be done like this:
|
||||
|
||||
```rust
|
||||
use async_std::io;
|
||||
|
||||
async fn echo(stream: io::TcpStream) {
|
||||
let (reader, writer) = &mut (&stream, &stream);
|
||||
io::copy(reader, writer).await?;
|
||||
}
|
||||
```
|
@ -0,0 +1 @@
|
||||
# Testing
|
@ -0,0 +1,12 @@
|
||||
# Security
|
||||
|
||||
Writing a highly perfomant async core library is a task involving some instances of unsafe code.
|
||||
|
||||
We take great care in vetting all unsafe code included in `async-std` and do follow generally accepted practices.
|
||||
|
||||
In the case that you find a security-related bug in our library, please get in touch with our [security contact][security-policy].
|
||||
|
||||
Patches improving the resilience of the library or the testing setup are happily accepted on our [github org][github].
|
||||
|
||||
[security-policies]: /security/policy
|
||||
[github]: https://github.com/async-std/
|
@ -0,0 +1 @@
|
||||
# Tutorials
|
@ -0,0 +1,43 @@
|
||||
# Exercise: Waiting for `std::thread`
|
||||
|
||||
Parallel processing is usually done via [threads].
|
||||
In `async-std`, we have similar concept, called a [`task`].
|
||||
These two worlds seem different - and in some regards, they are - though they
|
||||
are easy to connect.
|
||||
In this exercise, you will learn how to connect to concurrent/parallel components easily, by connecting a thread to a task.
|
||||
|
||||
## Understanding the problem
|
||||
|
||||
The standard thread API in Rust is `std::thread`. Specifically, it contains the [`spawn`] function, which allows us to start a thread:
|
||||
|
||||
```rust
|
||||
std::thread::spawn(|| {
|
||||
println!("in child thread");
|
||||
})
|
||||
println!("in parent thread");
|
||||
```
|
||||
|
||||
This creates a thread, _immediately_ [schedules] it to run, and continues. This is crucial: once the thread is spawned, it is independent of its _parent thread_. If you want to wait for the thread to end, you need to capture its [`JoinHandle`] and join it with your current thread:
|
||||
|
||||
```rust
|
||||
let thread = std::thread::spawn(|| {
|
||||
println!("in child thread");
|
||||
})
|
||||
thread.join();
|
||||
println!("in parent thread");
|
||||
```
|
||||
|
||||
This comes at a cost though: the waiting thread will [block] until the child is done. Wouldn't it be nice if we could just use the `.await` syntax here and leave the opportunity for another task to be scheduled while waiting?
|
||||
|
||||
## Backchannels
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[threads]: TODO: wikipedia
|
||||
[`task`]: TODO: docs link
|
||||
[`spawn`]: TODO: docs link
|
||||
[`JoinHandle`]: TODO: docs link
|
||||
[schedules]: TODO: Glossary link
|
||||
[block]: TODO: Link to blocking
|
Loading…
Reference in New Issue