Bug 1810615 - Update the async-task crate, r=supply-chain-reviewers,emilio

Differential Revision: https://phabricator.services.mozilla.com/D168175
This commit is contained in:
Nika Layzell 2023-01-31 20:35:32 +00:00
parent f40a982dd9
commit 8d5ea433cf
14 changed files with 679 additions and 89 deletions

View file

@ -125,11 +125,6 @@ git = "https://github.com/servo/rust-cssparser"
rev = "d3670a89bae26ba3a8db4758eb7976616113987d"
replace-with = "vendored-sources"
[source."https://github.com/smol-rs/async-task"]
git = "https://github.com/smol-rs/async-task"
rev = "f6488e35beccb26eb6e85847b02aa78a42cd3d0e"
replace-with = "vendored-sources"
# Take advantage of the fact that cargo will treat lines starting with #
# as comments to add preprocessing directives. This file can thus by copied

5
Cargo.lock generated
View file

@ -204,8 +204,9 @@ dependencies = [
[[package]]
name = "async-task"
version = "4.0.3"
source = "git+https://github.com/smol-rs/async-task?rev=f6488e35beccb26eb6e85847b02aa78a42cd3d0e#f6488e35beccb26eb6e85847b02aa78a42cd3d0e"
version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524"
[[package]]
name = "async-trait"

View file

@ -153,7 +153,6 @@ moz_asserts = { path = "mozglue/static/rust/moz_asserts" }
rure = { path = "third_party/rust/rure" }
# Other overrides
async-task = { git = "https://github.com/smol-rs/async-task", rev="f6488e35beccb26eb6e85847b02aa78a42cd3d0e" }
chardetng = { git = "https://github.com/hsivonen/chardetng", rev="3484d3e3ebdc8931493aa5df4d7ee9360a90e76b" }
chardetng_c = { git = "https://github.com/hsivonen/chardetng_c", rev="ed8a4c6f900a90d4dbc1d64b856e61490a1c3570" }
coremidi = { git = "https://github.com/chris-zen/coremidi.git", rev="fc68464b5445caf111e41f643a2e69ccce0b4f83" }

View file

@ -130,6 +130,12 @@ criteria = "safe-to-deploy"
delta = "4.0.3 -> 4.0.3@git:f6488e35beccb26eb6e85847b02aa78a42cd3d0e"
notes = "Recorded by bholley, confirmed over slack."
[[audits.async-task]]
who = "Nika Layzell <nika@thelayzells.com>"
criteria = "safe-to-deploy"
delta = "4.0.3 -> 4.3.0"
notes = "Main addition is the new FallibleTask type, which I implemented. No risky unsafe code changes."
[[audits.async-trait]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"

View file

@ -7,10 +7,6 @@ url = "https://raw.githubusercontent.com/bytecodealliance/wasmtime/main/supply-c
[imports.embark]
url = "https://raw.githubusercontent.com/EmbarkStudios/rust-ecosystem/main/audits.toml"
[policy.async-task]
audit-as-crates-io = true
notes = "This is the upstream code plus an extra fix that hasn't been released yet, see bug 1746533."
[policy.audioipc-client]
criteria = []
notes = "Going away very soon in bug 1697845"

View file

@ -1 +1 @@
{"files":{"CHANGELOG.md":"c4c2357aca3a55880f58ce71001fe55a2ad5b08c272cbbeb5f55888b3c405a8a","Cargo.toml":"e10e2b49a756cd051f1b642c51df4a8387965078c2fd4c885f6388a66c6ab56d","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"91a65b44a1692a16fa2d2f5bb424e78177f0c0ca0051e93db20443568377d5e5","benches/spawn.rs":"9272992dbc058734be04e4b1c0c92fa16f62eebe062c2ce74bbedfae1ce36689","examples/spawn-local.rs":"729d6b8ef55fad9387e8912567160766fb00c3880a7acbdcab7316aefe7811c3","examples/spawn-on-thread.rs":"90c5ffcbe11b847a9201a83ac2f036bf1721dfe971708781a0769ef8354e87c9","examples/spawn.rs":"360c86d609eea98333ba6284ebf8eeb73acc651f07d30b0dd5879757b4bf6125","src/header.rs":"956b92793bd20ef94b300cda3e7e9e70cadcbd6f5b57c7f0053e6f81e6002867","src/lib.rs":"f579f26e7b7b7c521f280ec876202650f4bac4d573734f40f05204d74327ed73","src/raw.rs":"6c3650d79e39f898826ddebd0eea37305b1013e427eaff331e7da3c71da247ab","src/runnable.rs":"24a2e33464a17bff4828e655ac77a6c7b87a335f35f8dc00b614d7542bdaf955","src/state.rs":"73ec4b98e8519faad882c1ee19711066a9e2a9b2cf9441436f145c8597e2b93d","src/task.rs":"5e822d51335139d9fa49655027150de43dd72fd6852a41c0bcb3f9e5dcae0e4b","src/utils.rs":"233350fa35223b286d144194b04c0549c3b7d2e378e1f61d7d31a807e1416d17","tests/basic.rs":"2346fc837af82d1f76f1dc2c799b0b4b35b92e61455b40e37d2698e87be84a42","tests/cancel.rs":"3316abbad56d06e1690e7d547aeec4acf3f4e2a84607684f840d6cb13ec5b057","tests/join.rs":"815e628cb77f1d42bdc0455a71818278e0a8b381efc090f8f843115b23ea734a","tests/panic.rs":"22bf21ce9a0b6d5558a54207a86aa2c3b13475aacccce7f619427056660fa427","tests/ready.rs":"357112e398d1f982585c76c2f49325ab1f2673f026c120fb10d9b92ee42188af","tests/waker_panic.rs":"9777f381d3c9a98fef9e480345d2df18dec286118fef5f7f18033b08a43e0cec","tests/waker_pending.rs":"40dcf6eac4f0902e888657883be411bb376ab7db53a3c720a84fe122539508e6","tests/waker_ready.rs":"4b230ebf2af301058771d78350bbb558f96eafaa2aee18ec5cfed74d5e3f3628"},"package":null}
{"files":{"CHANGELOG.md":"c80832a269fb7f86ccf0c8beddfdf7b4fce13a460156df7c0e43de4076d95b46","Cargo.lock":"82e2579ff5a0d32d975f4926a23ea51258fa70e2b72300802a8529ad58fc6b93","Cargo.toml":"ad0405c76d37e5e37fd69d758275f89829219e77242ffd907c62a6c7115a476a","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"91a65b44a1692a16fa2d2f5bb424e78177f0c0ca0051e93db20443568377d5e5","benches/spawn.rs":"9272992dbc058734be04e4b1c0c92fa16f62eebe062c2ce74bbedfae1ce36689","examples/spawn-local.rs":"729d6b8ef55fad9387e8912567160766fb00c3880a7acbdcab7316aefe7811c3","examples/spawn-on-thread.rs":"90c5ffcbe11b847a9201a83ac2f036bf1721dfe971708781a0769ef8354e87c9","examples/spawn.rs":"360c86d609eea98333ba6284ebf8eeb73acc651f07d30b0dd5879757b4bf6125","src/header.rs":"956b92793bd20ef94b300cda3e7e9e70cadcbd6f5b57c7f0053e6f81e6002867","src/lib.rs":"022fe8c25de431a2902a3cc5c207c4005b0519f121e1b6d90156dc5fc43f3593","src/raw.rs":"fd3d7e14fb6fb75006a7e3d221870e83d1cb5c6024f31173277da713fe90f485","src/runnable.rs":"24a2e33464a17bff4828e655ac77a6c7b87a335f35f8dc00b614d7542bdaf955","src/state.rs":"73ec4b98e8519faad882c1ee19711066a9e2a9b2cf9441436f145c8597e2b93d","src/task.rs":"403848eaee565a807d12b774094d12e6567ed3e418dc4c00e1b7a16e6c24fd0c","src/utils.rs":"67d76ad2aecc307f6e4a7d4a641ae34f3aad77bc6576ece2e0d9e7302b3a9aea","tests/basic.rs":"2346fc837af82d1f76f1dc2c799b0b4b35b92e61455b40e37d2698e87be84a42","tests/cancel.rs":"3316abbad56d06e1690e7d547aeec4acf3f4e2a84607684f840d6cb13ec5b057","tests/join.rs":"815e628cb77f1d42bdc0455a71818278e0a8b381efc090f8f843115b23ea734a","tests/panic.rs":"22bf21ce9a0b6d5558a54207a86aa2c3b13475aacccce7f619427056660fa427","tests/ready.rs":"357112e398d1f982585c76c2f49325ab1f2673f026c120fb10d9b92ee42188af","tests/waker_panic.rs":"9777f381d3c9a98fef9e480345d2df18dec286118fef5f7f18033b08a43e0cec","tests/waker_pending.rs":"40dcf6eac4f0902e888657883be411bb376ab7db53a3c720a84fe122539508e6","tests/waker_ready.rs":"4b230ebf2af301058771d78350bbb558f96eafaa2aee18ec5cfed74d5e3f3628"},"package":"7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524"}

View file

@ -1,3 +1,17 @@
# Version 4.3.0
- Bump MSRV to Rust 1.47. (#30)
- Evaluate the layouts for the tasks at compile time. (#30)
- Add layout_info field to TaskVTable so that debuggers can decode raw tasks. (#29)
# Version 4.2.0
- Add `Task::is_finished`. (#19)
# Version 4.1.0
- Add `FallibleTask`. (#21)
# Version 4.0.3
- Document the return value of `Runnable::run()` better.

443
third_party/rust/async-task/Cargo.lock generated vendored Normal file
View file

@ -0,0 +1,443 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "async-channel"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319"
dependencies = [
"concurrent-queue",
"event-listener",
"futures-core",
]
[[package]]
name = "async-executor"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965"
dependencies = [
"async-task 4.2.0",
"concurrent-queue",
"fastrand",
"futures-lite",
"once_cell",
"slab",
]
[[package]]
name = "async-fs"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b3ca4f8ff117c37c278a2f7415ce9be55560b846b5bc4412aaa5d29c1c3dae2"
dependencies = [
"async-lock",
"blocking",
"futures-lite",
]
[[package]]
name = "async-io"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5e18f61464ae81cde0a23e713ae8fd299580c54d697a35820cfd0625b8b0e07"
dependencies = [
"concurrent-queue",
"futures-lite",
"libc",
"log",
"once_cell",
"parking",
"polling",
"slab",
"socket2",
"waker-fn",
"winapi",
]
[[package]]
name = "async-lock"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e97a171d191782fba31bb902b14ad94e24a68145032b7eedf871ab0bc0d077b6"
dependencies = [
"event-listener",
]
[[package]]
name = "async-net"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5373304df79b9b4395068fb080369ec7178608827306ce4d081cba51cac551df"
dependencies = [
"async-io",
"blocking",
"futures-lite",
]
[[package]]
name = "async-process"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf2c06e30a24e8c78a3987d07f0930edf76ef35e027e7bdb063fccafdad1f60c"
dependencies = [
"async-io",
"blocking",
"cfg-if",
"event-listener",
"futures-lite",
"libc",
"once_cell",
"signal-hook",
"winapi",
]
[[package]]
name = "async-task"
version = "4.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9"
[[package]]
name = "async-task"
version = "4.3.0"
dependencies = [
"atomic-waker",
"easy-parallel",
"flaky_test",
"flume",
"once_cell",
"smol",
]
[[package]]
name = "atomic-waker"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a"
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "blocking"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc"
dependencies = [
"async-channel",
"async-task 4.2.0",
"atomic-waker",
"fastrand",
"futures-lite",
"once_cell",
]
[[package]]
name = "cache-padded"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"
[[package]]
name = "cc"
version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "concurrent-queue"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3"
dependencies = [
"cache-padded",
]
[[package]]
name = "easy-parallel"
version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6907e25393cdcc1f4f3f513d9aac1e840eb1cc341a0fccb01171f7d14d10b946"
[[package]]
name = "event-listener"
version = "2.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71"
[[package]]
name = "fastrand"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf"
dependencies = [
"instant",
]
[[package]]
name = "flaky_test"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "479cde5eb168cf5a056dd98f311cbfab7494c216394e4fb9eba0336827a8db93"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "flume"
version = "0.10.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ceeb589a3157cac0ab8cc585feb749bd2cea5cb55a6ee802ad72d9fd38303da"
dependencies = [
"spin",
]
[[package]]
name = "futures-core"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3"
[[package]]
name = "futures-io"
version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b"
[[package]]
name = "futures-lite"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48"
dependencies = [
"fastrand",
"futures-core",
"futures-io",
"memchr",
"parking",
"pin-project-lite",
"waker-fn",
]
[[package]]
name = "instant"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [
"cfg-if",
]
[[package]]
name = "libc"
version = "0.2.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
[[package]]
name = "lock_api"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if",
]
[[package]]
name = "memchr"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "once_cell"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
[[package]]
name = "parking"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72"
[[package]]
name = "pin-project-lite"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
[[package]]
name = "polling"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "685404d509889fade3e86fe3a5803bca2ec09b0c0778d5ada6ec8bf7a8de5259"
dependencies = [
"cfg-if",
"libc",
"log",
"wepoll-ffi",
"winapi",
]
[[package]]
name = "proc-macro2"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
dependencies = [
"proc-macro2",
]
[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "signal-hook"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d"
dependencies = [
"libc",
"signal-hook-registry",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0"
dependencies = [
"libc",
]
[[package]]
name = "slab"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32"
[[package]]
name = "smol"
version = "1.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85cf3b5351f3e783c1d79ab5fc604eeed8b8ae9abd36b166e8b87a089efd85e4"
dependencies = [
"async-channel",
"async-executor",
"async-fs",
"async-io",
"async-lock",
"async-net",
"async-process",
"blocking",
"futures-lite",
"once_cell",
]
[[package]]
name = "socket2"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "spin"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c530c2b0d0bf8b69304b39fe2001993e267461948b890cd037d8ad4293fa1a0d"
dependencies = [
"lock_api",
]
[[package]]
name = "syn"
version = "1.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
[[package]]
name = "waker-fn"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"
[[package]]
name = "wepoll-ffi"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb"
dependencies = [
"cc",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View file

@ -1,31 +1,56 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
name = "async-task"
# When publishing a new version:
# - Update CHANGELOG.md
# - Create "v4.x.y" git tag
version = "4.0.3"
authors = ["Stjepan Glavina <stjepang@gmail.com>"]
edition = "2018"
rust-version = "1.39"
rust-version = "1.47"
name = "async-task"
version = "4.3.0"
authors = ["Stjepan Glavina <stjepang@gmail.com>"]
exclude = ["/.*"]
description = "Task abstraction for building executors"
readme = "README.md"
keywords = [
"futures",
"task",
"executor",
"spawn",
]
categories = [
"asynchronous",
"concurrency",
"no-std",
]
license = "Apache-2.0 OR MIT"
repository = "https://github.com/smol-rs/async-task"
description = "Task abstraction for building executors"
keywords = ["futures", "task", "executor", "spawn"]
categories = ["asynchronous", "concurrency", "no-std"]
exclude = ["/.*"]
[dev-dependencies.atomic-waker]
version = "1"
[dev-dependencies.easy-parallel]
version = "3"
[dev-dependencies.flaky_test]
version = "0.1"
[dev-dependencies.flume]
version = "0.10"
default-features = false
[dev-dependencies.once_cell]
version = "1"
[dev-dependencies.smol]
version = "1"
[features]
default = ["std"]
std = []
[dev-dependencies]
atomic-waker = "1"
easy-parallel = "3"
flaky_test = "0.1"
flume = { version = "0.10", default-features = false }
once_cell = "1"
smol = "1"
# rewrite dependencies to use the this version of async-task when running tests
[patch.crates-io]
async-task = { path = "." }

View file

@ -74,6 +74,17 @@
extern crate alloc;
/// We can't use `?` in const contexts yet, so this macro acts
/// as a workaround.
macro_rules! leap {
($x: expr) => {{
match ($x) {
Some(val) => val,
None => return None,
}
}};
}
mod header;
mod raw;
mod runnable;

View file

@ -1,4 +1,4 @@
use alloc::alloc::Layout;
use alloc::alloc::Layout as StdLayout;
use core::cell::UnsafeCell;
use core::future::Future;
use core::mem::{self, ManuallyDrop};
@ -9,7 +9,7 @@ use core::task::{Context, Poll, RawWaker, RawWakerVTable, Waker};
use crate::header::Header;
use crate::state::*;
use crate::utils::{abort, abort_on_panic, extend};
use crate::utils::{abort, abort_on_panic, max, Layout};
use crate::Runnable;
/// The vtable for a task.
@ -34,6 +34,12 @@ pub(crate) struct TaskVTable {
/// Creates a new waker associated with the task.
pub(crate) clone_waker: unsafe fn(ptr: *const ()) -> RawWaker,
/// The memory layout of the task. This information enables
/// debuggers to decode raw task memory blobs. Do not remove
/// the field, even if it appears to be unused.
#[allow(unused)]
pub(crate) layout_info: &'static Option<TaskLayout>,
}
/// Memory layout of a task.
@ -45,7 +51,7 @@ pub(crate) struct TaskVTable {
#[derive(Clone, Copy)]
pub(crate) struct TaskLayout {
/// Memory layout of the whole task.
pub(crate) layout: Layout,
pub(crate) layout: StdLayout,
/// Offset into the task at which the schedule function is stored.
pub(crate) offset_s: usize,
@ -80,6 +86,39 @@ impl<F, T, S> Clone for RawTask<F, T, S> {
}
}
impl<F, T, S> RawTask<F, T, S> {
const TASK_LAYOUT: Option<TaskLayout> = Self::eval_task_layout();
/// Computes the memory layout for a task.
#[inline]
const fn eval_task_layout() -> Option<TaskLayout> {
// Compute the layouts for `Header`, `S`, `F`, and `T`.
let layout_header = Layout::new::<Header>();
let layout_s = Layout::new::<S>();
let layout_f = Layout::new::<F>();
let layout_r = Layout::new::<T>();
// Compute the layout for `union { F, T }`.
let size_union = max(layout_f.size(), layout_r.size());
let align_union = max(layout_f.align(), layout_r.align());
let layout_union = Layout::from_size_align(size_union, align_union);
// Compute the layout for `Header` followed `S` and `union { F, T }`.
let layout = layout_header;
let (layout, offset_s) = leap!(layout.extend(layout_s));
let (layout, offset_union) = leap!(layout.extend(layout_union));
let offset_f = offset_union;
let offset_r = offset_union;
Some(TaskLayout {
layout: unsafe { layout.into_std() },
offset_s,
offset_f,
offset_r,
})
}
}
impl<F, T, S> RawTask<F, T, S>
where
F: Future<Output = T>,
@ -97,7 +136,9 @@ where
/// It is assumed that initially only the `Runnable` and the `Task` exist.
pub(crate) fn allocate(future: F, schedule: S) -> NonNull<()> {
// Compute the layout of the task for allocation. Abort if the computation fails.
let task_layout = abort_on_panic(|| Self::task_layout());
//
// n.b. notgull: task_layout now automatically aborts instead of panicking
let task_layout = Self::task_layout();
unsafe {
// Allocate enough space for the entire task.
@ -120,6 +161,7 @@ where
destroy: Self::destroy,
run: Self::run,
clone_waker: Self::clone_waker,
layout_info: &Self::TASK_LAYOUT,
},
});
@ -149,32 +191,12 @@ where
}
}
/// Returns the memory layout for a task.
/// Returns the layout of the task.
#[inline]
fn task_layout() -> TaskLayout {
// Compute the layouts for `Header`, `S`, `F`, and `T`.
let layout_header = Layout::new::<Header>();
let layout_s = Layout::new::<S>();
let layout_f = Layout::new::<F>();
let layout_r = Layout::new::<T>();
// Compute the layout for `union { F, T }`.
let size_union = layout_f.size().max(layout_r.size());
let align_union = layout_f.align().max(layout_r.align());
let layout_union = unsafe { Layout::from_size_align_unchecked(size_union, align_union) };
// Compute the layout for `Header` followed `S` and `union { F, T }`.
let layout = layout_header;
let (layout, offset_s) = extend(layout, layout_s);
let (layout, offset_union) = extend(layout, layout_union);
let offset_f = offset_union;
let offset_r = offset_union;
TaskLayout {
layout,
offset_s,
offset_f,
offset_r,
match Self::TASK_LAYOUT {
Some(tl) => tl,
None => abort(),
}
}

View file

@ -99,6 +99,7 @@ impl<T> Task<T> {
/// # Examples
///
/// ```
/// # if cfg!(miri) { return; } // Miri does not support epoll
/// use smol::{future, Executor, Timer};
/// use std::thread;
/// use std::time::Duration;
@ -395,6 +396,19 @@ impl<T> Task<T> {
let header = ptr as *const Header;
unsafe { &*header }
}
/// Returns `true` if the current task is finished.
///
/// Note that in a multithreaded environment, this task can change finish immediately after calling this function.
pub fn is_finished(&self) -> bool {
let ptr = self.ptr.as_ptr();
let header = ptr as *const Header;
unsafe {
let state = (*header).state.load(Ordering::Acquire);
state & (CLOSED | COMPLETED) != 0
}
}
}
impl<T> Drop for Task<T> {
@ -472,6 +486,7 @@ impl<T> FallibleTask<T> {
/// # Examples
///
/// ```
/// # if cfg!(miri) { return; } // Miri does not support epoll
/// use smol::{future, Executor, Timer};
/// use std::thread;
/// use std::time::Duration;

View file

@ -1,4 +1,4 @@
use core::alloc::Layout;
use core::alloc::Layout as StdLayout;
use core::mem;
/// Aborts the process.
@ -36,29 +36,92 @@ pub(crate) fn abort_on_panic<T>(f: impl FnOnce() -> T) -> T {
t
}
/// Returns the layout for `a` followed by `b` and the offset of `b`.
///
/// This function was adapted from the currently unstable `Layout::extend()`:
/// https://doc.rust-lang.org/nightly/std/alloc/struct.Layout.html#method.extend
#[inline]
pub(crate) fn extend(a: Layout, b: Layout) -> (Layout, usize) {
let new_align = a.align().max(b.align());
let pad = padding_needed_for(a, b.align());
let offset = a.size().checked_add(pad).unwrap();
let new_size = offset.checked_add(b.size()).unwrap();
let layout = Layout::from_size_align(new_size, new_align).unwrap();
(layout, offset)
/// A version of `alloc::alloc::Layout` that can be used in the const
/// position.
#[derive(Clone, Copy, Debug)]
pub(crate) struct Layout {
size: usize,
align: usize,
}
/// Returns the padding after `layout` that aligns the following address to `align`.
///
/// This function was adapted from the currently unstable `Layout::padding_needed_for()`:
/// https://doc.rust-lang.org/nightly/std/alloc/struct.Layout.html#method.padding_needed_for
#[inline]
pub(crate) fn padding_needed_for(layout: Layout, align: usize) -> usize {
let len = layout.size();
let len_rounded_up = len.wrapping_add(align).wrapping_sub(1) & !align.wrapping_sub(1);
len_rounded_up.wrapping_sub(len)
impl Layout {
/// Creates a new `Layout` with the given size and alignment.
#[inline]
pub(crate) const fn from_size_align(size: usize, align: usize) -> Self {
Self { size, align }
}
/// Creates a new `Layout` for the given sized type.
#[inline]
pub(crate) const fn new<T>() -> Self {
Self::from_size_align(mem::size_of::<T>(), mem::align_of::<T>())
}
/// Convert this into the standard library's layout type.
///
/// # Safety
///
/// - `align` must be non-zero and a power of two.
/// - When rounded up to the nearest multiple of `align`, the size
/// must not overflow.
#[inline]
pub(crate) const unsafe fn into_std(self) -> StdLayout {
StdLayout::from_size_align_unchecked(self.size, self.align)
}
/// Get the alignment of this layout.
#[inline]
pub(crate) const fn align(&self) -> usize {
self.align
}
/// Get the size of this layout.
#[inline]
pub(crate) const fn size(&self) -> usize {
self.size
}
/// Returns the layout for `a` followed by `b` and the offset of `b`.
///
/// This function was adapted from the currently unstable `Layout::extend()`:
/// https://doc.rust-lang.org/nightly/std/alloc/struct.Layout.html#method.extend
#[inline]
pub(crate) const fn extend(self, other: Layout) -> Option<(Layout, usize)> {
let new_align = max(self.align(), other.align());
let pad = self.padding_needed_for(other.align());
let offset = leap!(self.size().checked_add(pad));
let new_size = leap!(offset.checked_add(other.size()));
// return None if any of the following are true:
// - align is 0 (implied false by is_power_of_two())
// - align is not a power of 2
// - size rounded up to align overflows
if !new_align.is_power_of_two() || new_size > core::usize::MAX - (new_align - 1) {
return None;
}
let layout = Layout::from_size_align(new_size, new_align);
Some((layout, offset))
}
/// Returns the padding after `layout` that aligns the following address to `align`.
///
/// This function was adapted from the currently unstable `Layout::padding_needed_for()`:
/// https://doc.rust-lang.org/nightly/std/alloc/struct.Layout.html#method.padding_needed_for
#[inline]
pub(crate) const fn padding_needed_for(self, align: usize) -> usize {
let len = self.size();
let len_rounded_up = len.wrapping_add(align).wrapping_sub(1) & !align.wrapping_sub(1);
len_rounded_up.wrapping_sub(len)
}
}
#[inline]
pub(crate) const fn max(left: usize, right: usize) -> usize {
if left > right {
left
} else {
right
}
}

View file

@ -10,7 +10,7 @@ edition = "2018"
log = "0.4"
cstr = "0.2"
libc = "0.2"
async-task = { version = "4.0" }
async-task = { version = "4.3" }
nserror = { path = "../nserror" }
nsstring = { path = "../nsstring" }
xpcom = { path = "../xpcom" }