diff options
Diffstat (limited to 'vendor/thread_local')
| -rw-r--r-- | vendor/thread_local/.cargo-checksum.json | 1 | ||||
| -rw-r--r-- | vendor/thread_local/CHANGELOG.md | 16 | ||||
| -rw-r--r-- | vendor/thread_local/Cargo.lock | 610 | ||||
| -rw-r--r-- | vendor/thread_local/Cargo.toml | 51 | ||||
| -rw-r--r-- | vendor/thread_local/LICENSE-APACHE | 201 | ||||
| -rw-r--r-- | vendor/thread_local/LICENSE-MIT | 25 | ||||
| -rw-r--r-- | vendor/thread_local/README.md | 39 | ||||
| -rw-r--r-- | vendor/thread_local/benches/thread_local.rs | 25 | ||||
| -rw-r--r-- | vendor/thread_local/src/cached.rs | 161 | ||||
| -rw-r--r-- | vendor/thread_local/src/lib.rs | 683 | ||||
| -rw-r--r-- | vendor/thread_local/src/thread_id.rs | 210 | ||||
| -rw-r--r-- | vendor/thread_local/src/unreachable.rs | 57 |
12 files changed, 0 insertions, 2079 deletions
diff --git a/vendor/thread_local/.cargo-checksum.json b/vendor/thread_local/.cargo-checksum.json deleted file mode 100644 index 0493c27b..00000000 --- a/vendor/thread_local/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{"CHANGELOG.md":"0130bc98dcaf6335344fe85a9efef31be7116e545198401e3c02268e7c5b71a8","Cargo.lock":"deb6fbac507b98ffe1385263a7ef399fa916fd5e360f23cab8c9067e533e803e","Cargo.toml":"54e1beedf0c7eeb77721fda4f8997295bf1e404fb9d092e87f81038e8e8fd466","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"c9a75f18b9ab2927829a208fc6aa2cf4e63b8420887ba29cdb265d6619ae82d5","README.md":"120dfd9b10dbf5f1c20f0be6943c9bec6543cebcebaf9d8ec4cf69bb52153e81","benches/thread_local.rs":"37dc7f2b6bc30ea093828ae0e5509dc5ffdf63fa8127804ff359e49e1175356e","src/cached.rs":"253cb48da470265f4c4702a4f9f6b8670860cb092d8304d807717d751d0b3350","src/lib.rs":"0dab6a6de9c6411bd3915deabc39c21d43b178836f714135d86c73fc13911244","src/thread_id.rs":"ac0f4cb9c7195217c09c9535987b986946b9ca2a17e1cfc73f2ae174ace4df58","src/unreachable.rs":"f0c65f1b0516cc92fbd7df2c8c8edfdac5362377d27ae5b91a12204673e2fd73"},"package":"f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185"}
\ No newline at end of file diff --git a/vendor/thread_local/CHANGELOG.md b/vendor/thread_local/CHANGELOG.md deleted file mode 100644 index c7440b79..00000000 --- a/vendor/thread_local/CHANGELOG.md +++ /dev/null @@ -1,16 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [Unreleased] - -## [1.1.9](https://github.com/Amanieu/thread_local-rs/compare/v1.1.8...v1.1.9) - 2025-06-12 - -### Other - -- Add release-plz for automated releases -- Remove once_cell dependency -- Bump MSRV to 1.61 diff --git a/vendor/thread_local/Cargo.lock b/vendor/thread_local/Cargo.lock deleted file mode 100644 index 84b23dea..00000000 --- a/vendor/thread_local/Cargo.lock +++ /dev/null @@ -1,610 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - -[[package]] -name = "anes" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" - -[[package]] -name = "anstyle" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bumpalo" -version = "3.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32a994c2b3ca201d9b263612a374263f05e7adde37c4707f693dcd375076d1f" - -[[package]] -name = "cast" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "ciborium" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" -dependencies = [ - "ciborium-io", - "ciborium-ll", - "serde", -] - -[[package]] -name = "ciborium-io" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" - -[[package]] -name = "ciborium-ll" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" -dependencies = [ - "ciborium-io", - "half", -] - -[[package]] -name = "clap" -version = "4.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" -dependencies = [ - "clap_builder", -] - -[[package]] -name = "clap_builder" -version = "4.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" -dependencies = [ - "anstyle", - "clap_lex", -] - -[[package]] -name = "clap_lex" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" - -[[package]] -name = "criterion" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" -dependencies = [ - "anes", - "cast", - "ciborium", - "clap", - "criterion-plot", - "is-terminal", - "itertools", - "num-traits", - "once_cell", - "oorandom", - "plotters", - "rayon", - "regex", - "serde", - "serde_derive", - "serde_json", - "tinytemplate", - "walkdir", -] - -[[package]] -name = "criterion-plot" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" -dependencies = [ - "cast", - "itertools", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "either" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" - -[[package]] -name = "half" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc52e53916c08643f1b56ec082790d1e86a32e58dc5268f897f313fbae7b4872" -dependencies = [ - "cfg-if", - "crunchy", -] - -[[package]] -name = "hermit-abi" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" - -[[package]] -name = "is-terminal" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys", -] - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" - -[[package]] -name = "js-sys" -version = "0.3.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "libc" -version = "0.2.153" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" - -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - -[[package]] -name = "memchr" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" - -[[package]] -name = "num-traits" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" -dependencies = [ - "autocfg", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "oorandom" -version = "11.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" - -[[package]] -name = "plotters" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" -dependencies = [ - "num-traits", - "plotters-backend", - "plotters-svg", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "plotters-backend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" - -[[package]] -name = "plotters-svg" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" -dependencies = [ - "plotters-backend", -] - -[[package]] -name = "proc-macro2" -version = "1.0.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rayon" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" -dependencies = [ - "crossbeam-deque", - "crossbeam-utils", -] - -[[package]] -name = "regex" -version = "1.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - -[[package]] -name = "ryu" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "serde" -version = "1.0.197" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.197" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.114" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "syn" -version = "2.0.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thread_local" -version = "1.1.9" -dependencies = [ - "cfg-if", - "criterion", -] - -[[package]] -name = "tinytemplate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" -dependencies = [ - "serde", - "serde_json", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "walkdir" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "wasm-bindgen" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" - -[[package]] -name = "web-sys" -version = "0.3.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[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-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" diff --git a/vendor/thread_local/Cargo.toml b/vendor/thread_local/Cargo.toml deleted file mode 100644 index 66a6b2da..00000000 --- a/vendor/thread_local/Cargo.toml +++ /dev/null @@ -1,51 +0,0 @@ -# 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] -edition = "2021" -rust-version = "1.63" -name = "thread_local" -version = "1.1.9" -authors = ["Amanieu d'Antras <amanieu@gmail.com>"] -build = false -autolib = false -autobins = false -autoexamples = false -autotests = false -autobenches = false -description = "Per-object thread-local storage" -documentation = "https://docs.rs/thread_local/" -readme = "README.md" -keywords = [ - "thread_local", - "concurrent", - "thread", -] -license = "MIT OR Apache-2.0" -repository = "https://github.com/Amanieu/thread_local-rs" - -[features] -nightly = [] - -[lib] -name = "thread_local" -path = "src/lib.rs" - -[[bench]] -name = "thread_local" -path = "benches/thread_local.rs" -harness = false - -[dependencies.cfg-if] -version = "1.0.0" - -[dev-dependencies.criterion] -version = "0.5.1" diff --git a/vendor/thread_local/LICENSE-APACHE b/vendor/thread_local/LICENSE-APACHE deleted file mode 100644 index 16fe87b0..00000000 --- a/vendor/thread_local/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/vendor/thread_local/LICENSE-MIT b/vendor/thread_local/LICENSE-MIT deleted file mode 100644 index 40b8817a..00000000 --- a/vendor/thread_local/LICENSE-MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2016 The Rust Project Developers - -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/vendor/thread_local/README.md b/vendor/thread_local/README.md deleted file mode 100644 index d055f9b5..00000000 --- a/vendor/thread_local/README.md +++ /dev/null @@ -1,39 +0,0 @@ -thread_local -============ - -[](https://github.com/Amanieu/thread_local-rs/actions) [](https://crates.io/crates/thread_local) - -This library provides the `ThreadLocal` type which allow a separate copy of an -object to be used for each thread. This allows for per-object thread-local -storage, unlike the standard library's `thread_local!` macro which only allows -static thread-local storage. - -[Documentation](https://docs.rs/thread_local/) - -## Usage - -Add this to your `Cargo.toml`: - -```toml -[dependencies] -thread_local = "1.1" -``` - -## Minimum Rust version - -This crate's minimum supported Rust version (MSRV) is 1.63.0. - -## License - -Licensed under either of - - * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) - * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) - -at your option. - -### Contribution - -Unless you explicitly state otherwise, any contribution intentionally submitted -for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any -additional terms or conditions. diff --git a/vendor/thread_local/benches/thread_local.rs b/vendor/thread_local/benches/thread_local.rs deleted file mode 100644 index dd4716d8..00000000 --- a/vendor/thread_local/benches/thread_local.rs +++ /dev/null @@ -1,25 +0,0 @@ -use criterion::{black_box, BatchSize}; - -use thread_local::ThreadLocal; - -fn main() { - let mut c = criterion::Criterion::default().configure_from_args(); - - c.bench_function("get", |b| { - let local = ThreadLocal::new(); - local.get_or(|| Box::new(0)); - b.iter(|| { - black_box(local.get()); - }); - }); - - c.bench_function("insert", |b| { - b.iter_batched_ref( - ThreadLocal::new, - |local| { - black_box(local.get_or(|| 0)); - }, - BatchSize::SmallInput, - ) - }); -} diff --git a/vendor/thread_local/src/cached.rs b/vendor/thread_local/src/cached.rs deleted file mode 100644 index 16f6516d..00000000 --- a/vendor/thread_local/src/cached.rs +++ /dev/null @@ -1,161 +0,0 @@ -#![allow(deprecated)] - -use super::{IntoIter, IterMut, ThreadLocal}; -use std::fmt; -use std::panic::UnwindSafe; -use std::usize; - -/// Wrapper around [`ThreadLocal`]. -/// -/// This used to add a fast path for a single thread, however that has been -/// obsoleted by performance improvements to [`ThreadLocal`] itself. -#[deprecated(since = "1.1.0", note = "Use `ThreadLocal` instead")] -pub struct CachedThreadLocal<T: Send> { - inner: ThreadLocal<T>, -} - -impl<T: Send> Default for CachedThreadLocal<T> { - fn default() -> CachedThreadLocal<T> { - CachedThreadLocal::new() - } -} - -impl<T: Send> CachedThreadLocal<T> { - /// Creates a new empty `CachedThreadLocal`. - #[inline] - pub fn new() -> CachedThreadLocal<T> { - CachedThreadLocal { - inner: ThreadLocal::new(), - } - } - - /// Returns the element for the current thread, if it exists. - #[inline] - pub fn get(&self) -> Option<&T> { - self.inner.get() - } - - /// Returns the element for the current thread, or creates it if it doesn't - /// exist. - #[inline] - pub fn get_or<F>(&self, create: F) -> &T - where - F: FnOnce() -> T, - { - self.inner.get_or(create) - } - - /// Returns the element for the current thread, or creates it if it doesn't - /// exist. If `create` fails, that error is returned and no element is - /// added. - #[inline] - pub fn get_or_try<F, E>(&self, create: F) -> Result<&T, E> - where - F: FnOnce() -> Result<T, E>, - { - self.inner.get_or_try(create) - } - - /// Returns a mutable iterator over the local values of all threads. - /// - /// Since this call borrows the `ThreadLocal` mutably, this operation can - /// be done safely---the mutable borrow statically guarantees no other - /// threads are currently accessing their associated values. - #[inline] - pub fn iter_mut(&mut self) -> CachedIterMut<T> { - CachedIterMut { - inner: self.inner.iter_mut(), - } - } - - /// Removes all thread-specific values from the `ThreadLocal`, effectively - /// reseting it to its original state. - /// - /// Since this call borrows the `ThreadLocal` mutably, this operation can - /// be done safely---the mutable borrow statically guarantees no other - /// threads are currently accessing their associated values. - #[inline] - pub fn clear(&mut self) { - self.inner.clear(); - } -} - -impl<T: Send> IntoIterator for CachedThreadLocal<T> { - type Item = T; - type IntoIter = CachedIntoIter<T>; - - fn into_iter(self) -> CachedIntoIter<T> { - CachedIntoIter { - inner: self.inner.into_iter(), - } - } -} - -impl<'a, T: Send + 'a> IntoIterator for &'a mut CachedThreadLocal<T> { - type Item = &'a mut T; - type IntoIter = CachedIterMut<'a, T>; - - fn into_iter(self) -> CachedIterMut<'a, T> { - self.iter_mut() - } -} - -impl<T: Send + Default> CachedThreadLocal<T> { - /// Returns the element for the current thread, or creates a default one if - /// it doesn't exist. - pub fn get_or_default(&self) -> &T { - self.get_or(T::default) - } -} - -impl<T: Send + fmt::Debug> fmt::Debug for CachedThreadLocal<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "ThreadLocal {{ local_data: {:?} }}", self.get()) - } -} - -impl<T: Send + UnwindSafe> UnwindSafe for CachedThreadLocal<T> {} - -/// Mutable iterator over the contents of a `CachedThreadLocal`. -#[deprecated(since = "1.1.0", note = "Use `IterMut` instead")] -pub struct CachedIterMut<'a, T: Send + 'a> { - inner: IterMut<'a, T>, -} - -impl<'a, T: Send + 'a> Iterator for CachedIterMut<'a, T> { - type Item = &'a mut T; - - #[inline] - fn next(&mut self) -> Option<&'a mut T> { - self.inner.next() - } - - #[inline] - fn size_hint(&self) -> (usize, Option<usize>) { - self.inner.size_hint() - } -} - -impl<'a, T: Send + 'a> ExactSizeIterator for CachedIterMut<'a, T> {} - -/// An iterator that moves out of a `CachedThreadLocal`. -#[deprecated(since = "1.1.0", note = "Use `IntoIter` instead")] -pub struct CachedIntoIter<T: Send> { - inner: IntoIter<T>, -} - -impl<T: Send> Iterator for CachedIntoIter<T> { - type Item = T; - - #[inline] - fn next(&mut self) -> Option<T> { - self.inner.next() - } - - #[inline] - fn size_hint(&self) -> (usize, Option<usize>) { - self.inner.size_hint() - } -} - -impl<T: Send> ExactSizeIterator for CachedIntoIter<T> {} diff --git a/vendor/thread_local/src/lib.rs b/vendor/thread_local/src/lib.rs deleted file mode 100644 index c6ae6860..00000000 --- a/vendor/thread_local/src/lib.rs +++ /dev/null @@ -1,683 +0,0 @@ -// Copyright 2017 Amanieu d'Antras -// -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. - -//! Per-object thread-local storage -//! -//! This library provides the `ThreadLocal` type which allows a separate copy of -//! an object to be used for each thread. This allows for per-object -//! thread-local storage, unlike the standard library's `thread_local!` macro -//! which only allows static thread-local storage. -//! -//! Per-thread objects are not destroyed when a thread exits. Instead, objects -//! are only destroyed when the `ThreadLocal` containing them is destroyed. -//! -//! You can also iterate over the thread-local values of all thread in a -//! `ThreadLocal` object using the `iter_mut` and `into_iter` methods. This can -//! only be done if you have mutable access to the `ThreadLocal` object, which -//! guarantees that you are the only thread currently accessing it. -//! -//! Note that since thread IDs are recycled when a thread exits, it is possible -//! for one thread to retrieve the object of another thread. Since this can only -//! occur after a thread has exited this does not lead to any race conditions. -//! -//! # Examples -//! -//! Basic usage of `ThreadLocal`: -//! -//! ```rust -//! use thread_local::ThreadLocal; -//! let tls: ThreadLocal<u32> = ThreadLocal::new(); -//! assert_eq!(tls.get(), None); -//! assert_eq!(tls.get_or(|| 5), &5); -//! assert_eq!(tls.get(), Some(&5)); -//! ``` -//! -//! Combining thread-local values into a single result: -//! -//! ```rust -//! use thread_local::ThreadLocal; -//! use std::sync::Arc; -//! use std::cell::Cell; -//! use std::thread; -//! -//! let tls = Arc::new(ThreadLocal::new()); -//! -//! // Create a bunch of threads to do stuff -//! for _ in 0..5 { -//! let tls2 = tls.clone(); -//! thread::spawn(move || { -//! // Increment a counter to count some event... -//! let cell = tls2.get_or(|| Cell::new(0)); -//! cell.set(cell.get() + 1); -//! }).join().unwrap(); -//! } -//! -//! // Once all threads are done, collect the counter values and return the -//! // sum of all thread-local counter values. -//! let tls = Arc::try_unwrap(tls).unwrap(); -//! let total = tls.into_iter().fold(0, |x, y| x + y.get()); -//! assert_eq!(total, 5); -//! ``` - -#![warn(missing_docs)] -#![allow(clippy::mutex_atomic)] -#![cfg_attr(feature = "nightly", feature(thread_local))] - -mod cached; -mod thread_id; -mod unreachable; - -#[allow(deprecated)] -pub use cached::{CachedIntoIter, CachedIterMut, CachedThreadLocal}; - -use std::cell::UnsafeCell; -use std::fmt; -use std::iter::FusedIterator; -use std::mem; -use std::mem::MaybeUninit; -use std::panic::UnwindSafe; -use std::ptr; -use std::sync::atomic::{AtomicBool, AtomicPtr, AtomicUsize, Ordering}; -use thread_id::Thread; -use unreachable::UncheckedResultExt; - -// Use usize::BITS once it has stabilized and the MSRV has been bumped. -#[cfg(target_pointer_width = "16")] -const POINTER_WIDTH: u8 = 16; -#[cfg(target_pointer_width = "32")] -const POINTER_WIDTH: u8 = 32; -#[cfg(target_pointer_width = "64")] -const POINTER_WIDTH: u8 = 64; - -/// The total number of buckets stored in each thread local. -/// All buckets combined can hold up to `usize::MAX - 1` entries. -const BUCKETS: usize = (POINTER_WIDTH - 1) as usize; - -/// Thread-local variable wrapper -/// -/// See the [module-level documentation](index.html) for more. -pub struct ThreadLocal<T: Send> { - /// The buckets in the thread local. The nth bucket contains `2^n` - /// elements. Each bucket is lazily allocated. - buckets: [AtomicPtr<Entry<T>>; BUCKETS], - - /// The number of values in the thread local. This can be less than the real number of values, - /// but is never more. - values: AtomicUsize, -} - -struct Entry<T> { - present: AtomicBool, - value: UnsafeCell<MaybeUninit<T>>, -} - -impl<T> Drop for Entry<T> { - fn drop(&mut self) { - unsafe { - if *self.present.get_mut() { - ptr::drop_in_place((*self.value.get()).as_mut_ptr()); - } - } - } -} - -// ThreadLocal is always Sync, even if T isn't -unsafe impl<T: Send> Sync for ThreadLocal<T> {} - -impl<T: Send> Default for ThreadLocal<T> { - fn default() -> ThreadLocal<T> { - ThreadLocal::new() - } -} - -impl<T: Send> Drop for ThreadLocal<T> { - fn drop(&mut self) { - // Free each non-null bucket - for (i, bucket) in self.buckets.iter_mut().enumerate() { - let bucket_ptr = *bucket.get_mut(); - - let this_bucket_size = 1 << i; - - if bucket_ptr.is_null() { - continue; - } - - unsafe { deallocate_bucket(bucket_ptr, this_bucket_size) }; - } - } -} - -impl<T: Send> ThreadLocal<T> { - /// Creates a new empty `ThreadLocal`. - pub const fn new() -> ThreadLocal<T> { - let buckets = [ptr::null_mut::<Entry<T>>(); BUCKETS]; - Self { - buckets: unsafe { mem::transmute(buckets) }, - values: AtomicUsize::new(0), - } - } - - /// Creates a new `ThreadLocal` with an initial capacity. If less than the capacity threads - /// access the thread local it will never reallocate. The capacity may be rounded up to the - /// nearest power of two. - pub fn with_capacity(capacity: usize) -> ThreadLocal<T> { - let allocated_buckets = usize::from(POINTER_WIDTH) - (capacity.leading_zeros() as usize); - - let mut buckets = [ptr::null_mut(); BUCKETS]; - for (i, bucket) in buckets[..allocated_buckets].iter_mut().enumerate() { - *bucket = allocate_bucket::<T>(1 << i); - } - - Self { - // Safety: AtomicPtr has the same representation as a pointer and arrays have the same - // representation as a sequence of their inner type. - buckets: unsafe { mem::transmute(buckets) }, - values: AtomicUsize::new(0), - } - } - - /// Returns the element for the current thread, if it exists. - pub fn get(&self) -> Option<&T> { - self.get_inner(thread_id::get()) - } - - /// Returns the element for the current thread, or creates it if it doesn't - /// exist. - pub fn get_or<F>(&self, create: F) -> &T - where - F: FnOnce() -> T, - { - unsafe { - self.get_or_try(|| Ok::<T, ()>(create())) - .unchecked_unwrap_ok() - } - } - - /// Returns the element for the current thread, or creates it if it doesn't - /// exist. If `create` fails, that error is returned and no element is - /// added. - pub fn get_or_try<F, E>(&self, create: F) -> Result<&T, E> - where - F: FnOnce() -> Result<T, E>, - { - let thread = thread_id::get(); - if let Some(val) = self.get_inner(thread) { - return Ok(val); - } - - Ok(self.insert(thread, create()?)) - } - - fn get_inner(&self, thread: Thread) -> Option<&T> { - let bucket_ptr = - unsafe { self.buckets.get_unchecked(thread.bucket) }.load(Ordering::Acquire); - if bucket_ptr.is_null() { - return None; - } - unsafe { - let entry = &*bucket_ptr.add(thread.index); - if entry.present.load(Ordering::Relaxed) { - Some(&*(&*entry.value.get()).as_ptr()) - } else { - None - } - } - } - - #[cold] - fn insert(&self, thread: Thread, data: T) -> &T { - let bucket_atomic_ptr = unsafe { self.buckets.get_unchecked(thread.bucket) }; - let bucket_ptr: *const _ = bucket_atomic_ptr.load(Ordering::Acquire); - - // If the bucket doesn't already exist, we need to allocate it - let bucket_ptr = if bucket_ptr.is_null() { - let new_bucket = allocate_bucket(thread.bucket_size); - - match bucket_atomic_ptr.compare_exchange( - ptr::null_mut(), - new_bucket, - Ordering::AcqRel, - Ordering::Acquire, - ) { - Ok(_) => new_bucket, - // If the bucket value changed (from null), that means - // another thread stored a new bucket before we could, - // and we can free our bucket and use that one instead - Err(bucket_ptr) => { - unsafe { deallocate_bucket(new_bucket, thread.bucket_size) } - bucket_ptr - } - } - } else { - bucket_ptr - }; - - // Insert the new element into the bucket - let entry = unsafe { &*bucket_ptr.add(thread.index) }; - let value_ptr = entry.value.get(); - unsafe { value_ptr.write(MaybeUninit::new(data)) }; - entry.present.store(true, Ordering::Release); - - self.values.fetch_add(1, Ordering::Release); - - unsafe { &*(&*value_ptr).as_ptr() } - } - - /// Returns an iterator over the local values of all threads in unspecified - /// order. - /// - /// This call can be done safely, as `T` is required to implement [`Sync`]. - pub fn iter(&self) -> Iter<'_, T> - where - T: Sync, - { - Iter { - thread_local: self, - raw: RawIter::new(), - } - } - - /// Returns a mutable iterator over the local values of all threads in - /// unspecified order. - /// - /// Since this call borrows the `ThreadLocal` mutably, this operation can - /// be done safely---the mutable borrow statically guarantees no other - /// threads are currently accessing their associated values. - pub fn iter_mut(&mut self) -> IterMut<T> { - IterMut { - thread_local: self, - raw: RawIter::new(), - } - } - - /// Removes all thread-specific values from the `ThreadLocal`, effectively - /// reseting it to its original state. - /// - /// Since this call borrows the `ThreadLocal` mutably, this operation can - /// be done safely---the mutable borrow statically guarantees no other - /// threads are currently accessing their associated values. - pub fn clear(&mut self) { - *self = ThreadLocal::new(); - } -} - -impl<T: Send> IntoIterator for ThreadLocal<T> { - type Item = T; - type IntoIter = IntoIter<T>; - - fn into_iter(self) -> IntoIter<T> { - IntoIter { - thread_local: self, - raw: RawIter::new(), - } - } -} - -impl<'a, T: Send + Sync> IntoIterator for &'a ThreadLocal<T> { - type Item = &'a T; - type IntoIter = Iter<'a, T>; - - fn into_iter(self) -> Self::IntoIter { - self.iter() - } -} - -impl<'a, T: Send> IntoIterator for &'a mut ThreadLocal<T> { - type Item = &'a mut T; - type IntoIter = IterMut<'a, T>; - - fn into_iter(self) -> IterMut<'a, T> { - self.iter_mut() - } -} - -impl<T: Send + Default> ThreadLocal<T> { - /// Returns the element for the current thread, or creates a default one if - /// it doesn't exist. - pub fn get_or_default(&self) -> &T { - self.get_or(Default::default) - } -} - -impl<T: Send + fmt::Debug> fmt::Debug for ThreadLocal<T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "ThreadLocal {{ local_data: {:?} }}", self.get()) - } -} - -impl<T: Send + UnwindSafe> UnwindSafe for ThreadLocal<T> {} - -#[derive(Debug)] -struct RawIter { - yielded: usize, - bucket: usize, - bucket_size: usize, - index: usize, -} -impl RawIter { - #[inline] - fn new() -> Self { - Self { - yielded: 0, - bucket: 0, - bucket_size: 1, - index: 0, - } - } - - fn next<'a, T: Send + Sync>(&mut self, thread_local: &'a ThreadLocal<T>) -> Option<&'a T> { - while self.bucket < BUCKETS { - let bucket = unsafe { thread_local.buckets.get_unchecked(self.bucket) }; - let bucket = bucket.load(Ordering::Acquire); - - if !bucket.is_null() { - while self.index < self.bucket_size { - let entry = unsafe { &*bucket.add(self.index) }; - self.index += 1; - if entry.present.load(Ordering::Acquire) { - self.yielded += 1; - return Some(unsafe { &*(&*entry.value.get()).as_ptr() }); - } - } - } - - self.next_bucket(); - } - None - } - fn next_mut<'a, T: Send>( - &mut self, - thread_local: &'a mut ThreadLocal<T>, - ) -> Option<&'a mut Entry<T>> { - if *thread_local.values.get_mut() == self.yielded { - return None; - } - - loop { - let bucket = unsafe { thread_local.buckets.get_unchecked_mut(self.bucket) }; - let bucket = *bucket.get_mut(); - - if !bucket.is_null() { - while self.index < self.bucket_size { - let entry = unsafe { &mut *bucket.add(self.index) }; - self.index += 1; - if *entry.present.get_mut() { - self.yielded += 1; - return Some(entry); - } - } - } - - self.next_bucket(); - } - } - - #[inline] - fn next_bucket(&mut self) { - self.bucket_size <<= 1; - self.bucket += 1; - self.index = 0; - } - - fn size_hint<T: Send>(&self, thread_local: &ThreadLocal<T>) -> (usize, Option<usize>) { - let total = thread_local.values.load(Ordering::Acquire); - (total - self.yielded, None) - } - fn size_hint_frozen<T: Send>(&self, thread_local: &ThreadLocal<T>) -> (usize, Option<usize>) { - let total = unsafe { *(&thread_local.values as *const AtomicUsize as *const usize) }; - let remaining = total - self.yielded; - (remaining, Some(remaining)) - } -} - -/// Iterator over the contents of a `ThreadLocal`. -#[derive(Debug)] -pub struct Iter<'a, T: Send + Sync> { - thread_local: &'a ThreadLocal<T>, - raw: RawIter, -} - -impl<'a, T: Send + Sync> Iterator for Iter<'a, T> { - type Item = &'a T; - fn next(&mut self) -> Option<Self::Item> { - self.raw.next(self.thread_local) - } - fn size_hint(&self) -> (usize, Option<usize>) { - self.raw.size_hint(self.thread_local) - } -} -impl<T: Send + Sync> FusedIterator for Iter<'_, T> {} - -/// Mutable iterator over the contents of a `ThreadLocal`. -pub struct IterMut<'a, T: Send> { - thread_local: &'a mut ThreadLocal<T>, - raw: RawIter, -} - -impl<'a, T: Send> Iterator for IterMut<'a, T> { - type Item = &'a mut T; - fn next(&mut self) -> Option<&'a mut T> { - self.raw - .next_mut(self.thread_local) - .map(|entry| unsafe { &mut *(&mut *entry.value.get()).as_mut_ptr() }) - } - fn size_hint(&self) -> (usize, Option<usize>) { - self.raw.size_hint_frozen(self.thread_local) - } -} - -impl<T: Send> ExactSizeIterator for IterMut<'_, T> {} -impl<T: Send> FusedIterator for IterMut<'_, T> {} - -// Manual impl so we don't call Debug on the ThreadLocal, as doing so would create a reference to -// this thread's value that potentially aliases with a mutable reference we have given out. -impl<'a, T: Send + fmt::Debug> fmt::Debug for IterMut<'a, T> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("IterMut").field("raw", &self.raw).finish() - } -} - -/// An iterator that moves out of a `ThreadLocal`. -#[derive(Debug)] -pub struct IntoIter<T: Send> { - thread_local: ThreadLocal<T>, - raw: RawIter, -} - -impl<T: Send> Iterator for IntoIter<T> { - type Item = T; - fn next(&mut self) -> Option<T> { - self.raw.next_mut(&mut self.thread_local).map(|entry| { - *entry.present.get_mut() = false; - unsafe { - std::mem::replace(&mut *entry.value.get(), MaybeUninit::uninit()).assume_init() - } - }) - } - fn size_hint(&self) -> (usize, Option<usize>) { - self.raw.size_hint_frozen(&self.thread_local) - } -} - -impl<T: Send> ExactSizeIterator for IntoIter<T> {} -impl<T: Send> FusedIterator for IntoIter<T> {} - -fn allocate_bucket<T>(size: usize) -> *mut Entry<T> { - Box::into_raw( - (0..size) - .map(|_| Entry::<T> { - present: AtomicBool::new(false), - value: UnsafeCell::new(MaybeUninit::uninit()), - }) - .collect(), - ) as *mut _ -} - -unsafe fn deallocate_bucket<T>(bucket: *mut Entry<T>, size: usize) { - let _ = Box::from_raw(std::slice::from_raw_parts_mut(bucket, size)); -} - -#[cfg(test)] -mod tests { - use super::*; - - use std::cell::RefCell; - use std::sync::atomic::AtomicUsize; - use std::sync::atomic::Ordering::Relaxed; - use std::sync::Arc; - use std::thread; - - fn make_create() -> Arc<dyn Fn() -> usize + Send + Sync> { - let count = AtomicUsize::new(0); - Arc::new(move || count.fetch_add(1, Relaxed)) - } - - #[test] - fn same_thread() { - let create = make_create(); - let mut tls = ThreadLocal::new(); - assert_eq!(None, tls.get()); - assert_eq!("ThreadLocal { local_data: None }", format!("{:?}", &tls)); - assert_eq!(0, *tls.get_or(|| create())); - assert_eq!(Some(&0), tls.get()); - assert_eq!(0, *tls.get_or(|| create())); - assert_eq!(Some(&0), tls.get()); - assert_eq!(0, *tls.get_or(|| create())); - assert_eq!(Some(&0), tls.get()); - assert_eq!("ThreadLocal { local_data: Some(0) }", format!("{:?}", &tls)); - tls.clear(); - assert_eq!(None, tls.get()); - } - - #[test] - fn different_thread() { - let create = make_create(); - let tls = Arc::new(ThreadLocal::new()); - assert_eq!(None, tls.get()); - assert_eq!(0, *tls.get_or(|| create())); - assert_eq!(Some(&0), tls.get()); - - let tls2 = tls.clone(); - let create2 = create.clone(); - thread::spawn(move || { - assert_eq!(None, tls2.get()); - assert_eq!(1, *tls2.get_or(|| create2())); - assert_eq!(Some(&1), tls2.get()); - }) - .join() - .unwrap(); - - assert_eq!(Some(&0), tls.get()); - assert_eq!(0, *tls.get_or(|| create())); - } - - #[test] - fn iter() { - let tls = Arc::new(ThreadLocal::new()); - tls.get_or(|| Box::new(1)); - - let tls2 = tls.clone(); - thread::spawn(move || { - tls2.get_or(|| Box::new(2)); - let tls3 = tls2.clone(); - thread::spawn(move || { - tls3.get_or(|| Box::new(3)); - }) - .join() - .unwrap(); - drop(tls2); - }) - .join() - .unwrap(); - - let mut tls = Arc::try_unwrap(tls).unwrap(); - - let mut v = tls.iter().map(|x| **x).collect::<Vec<i32>>(); - v.sort_unstable(); - assert_eq!(vec![1, 2, 3], v); - - let mut v = tls.iter_mut().map(|x| **x).collect::<Vec<i32>>(); - v.sort_unstable(); - assert_eq!(vec![1, 2, 3], v); - - let mut v = tls.into_iter().map(|x| *x).collect::<Vec<i32>>(); - v.sort_unstable(); - assert_eq!(vec![1, 2, 3], v); - } - - #[test] - fn miri_iter_soundness_check() { - let tls = Arc::new(ThreadLocal::new()); - let _local = tls.get_or(|| Box::new(1)); - - let tls2 = tls.clone(); - let join_1 = thread::spawn(move || { - let _tls = tls2.get_or(|| Box::new(2)); - let iter = tls2.iter(); - for item in iter { - println!("{:?}", item); - } - }); - - let iter = tls.iter(); - for item in iter { - println!("{:?}", item); - } - - join_1.join().ok(); - } - - #[test] - fn test_drop() { - let local = ThreadLocal::new(); - struct Dropped(Arc<AtomicUsize>); - impl Drop for Dropped { - fn drop(&mut self) { - self.0.fetch_add(1, Relaxed); - } - } - - let dropped = Arc::new(AtomicUsize::new(0)); - local.get_or(|| Dropped(dropped.clone())); - assert_eq!(dropped.load(Relaxed), 0); - drop(local); - assert_eq!(dropped.load(Relaxed), 1); - } - - #[test] - fn test_earlyreturn_buckets() { - struct Dropped(Arc<AtomicUsize>); - impl Drop for Dropped { - fn drop(&mut self) { - self.0.fetch_add(1, Relaxed); - } - } - let dropped = Arc::new(AtomicUsize::new(0)); - - // We use a high `id` here to guarantee that a lazily allocated bucket somewhere in the middle is used. - // Neither iteration nor `Drop` must early-return on `null` buckets that are used for lower `buckets`. - let thread = Thread::new(1234); - assert!(thread.bucket > 1); - - let mut local = ThreadLocal::new(); - local.insert(thread, Dropped(dropped.clone())); - - let item = local.iter().next().unwrap(); - assert_eq!(item.0.load(Relaxed), 0); - let item = local.iter_mut().next().unwrap(); - assert_eq!(item.0.load(Relaxed), 0); - drop(local); - assert_eq!(dropped.load(Relaxed), 1); - } - - #[test] - fn is_sync() { - fn foo<T: Sync>() {} - foo::<ThreadLocal<String>>(); - foo::<ThreadLocal<RefCell<String>>>(); - } -} diff --git a/vendor/thread_local/src/thread_id.rs b/vendor/thread_local/src/thread_id.rs deleted file mode 100644 index 91b62337..00000000 --- a/vendor/thread_local/src/thread_id.rs +++ /dev/null @@ -1,210 +0,0 @@ -// Copyright 2017 Amanieu d'Antras -// -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. - -use crate::POINTER_WIDTH; -use std::cell::Cell; -use std::cmp::Reverse; -use std::collections::BinaryHeap; -use std::sync::Mutex; - -/// Thread ID manager which allocates thread IDs. It attempts to aggressively -/// reuse thread IDs where possible to avoid cases where a ThreadLocal grows -/// indefinitely when it is used by many short-lived threads. -struct ThreadIdManager { - free_from: usize, - free_list: Option<BinaryHeap<Reverse<usize>>>, -} - -impl ThreadIdManager { - const fn new() -> Self { - Self { - free_from: 0, - free_list: None, - } - } - - fn alloc(&mut self) -> usize { - if let Some(id) = self.free_list.as_mut().and_then(|heap| heap.pop()) { - id.0 - } else { - // `free_from` can't overflow as each thread takes up at least 2 bytes of memory and - // thus we can't even have `usize::MAX / 2 + 1` threads. - - let id = self.free_from; - self.free_from += 1; - id - } - } - - fn free(&mut self, id: usize) { - self.free_list - .get_or_insert_with(BinaryHeap::new) - .push(Reverse(id)); - } -} - -static THREAD_ID_MANAGER: Mutex<ThreadIdManager> = Mutex::new(ThreadIdManager::new()); - -/// Data which is unique to the current thread while it is running. -/// A thread ID may be reused after a thread exits. -#[derive(Clone, Copy)] -pub(crate) struct Thread { - /// The thread ID obtained from the thread ID manager. - pub(crate) id: usize, - /// The bucket this thread's local storage will be in. - pub(crate) bucket: usize, - /// The size of the bucket this thread's local storage will be in. - pub(crate) bucket_size: usize, - /// The index into the bucket this thread's local storage is in. - pub(crate) index: usize, -} -impl Thread { - pub(crate) fn new(id: usize) -> Self { - let bucket = usize::from(POINTER_WIDTH) - ((id + 1).leading_zeros() as usize) - 1; - let bucket_size = 1 << bucket; - let index = id - (bucket_size - 1); - - Self { - id, - bucket, - bucket_size, - index, - } - } -} - -cfg_if::cfg_if! { - if #[cfg(feature = "nightly")] { - // This is split into 2 thread-local variables so that we can check whether the - // thread is initialized without having to register a thread-local destructor. - // - // This makes the fast path smaller. - #[thread_local] - static mut THREAD: Option<Thread> = None; - thread_local! { static THREAD_GUARD: ThreadGuard = const { ThreadGuard { id: Cell::new(0) } }; } - - // Guard to ensure the thread ID is released on thread exit. - struct ThreadGuard { - // We keep a copy of the thread ID in the ThreadGuard: we can't - // reliably access THREAD in our Drop impl due to the unpredictable - // order of TLS destructors. - id: Cell<usize>, - } - - impl Drop for ThreadGuard { - fn drop(&mut self) { - // Release the thread ID. Any further accesses to the thread ID - // will go through get_slow which will either panic or - // initialize a new ThreadGuard. - unsafe { - THREAD = None; - } - THREAD_ID_MANAGER.lock().unwrap().free(self.id.get()); - } - } - - /// Returns a thread ID for the current thread, allocating one if needed. - #[inline] - pub(crate) fn get() -> Thread { - if let Some(thread) = unsafe { THREAD } { - thread - } else { - get_slow() - } - } - - /// Out-of-line slow path for allocating a thread ID. - #[cold] - fn get_slow() -> Thread { - let new = Thread::new(THREAD_ID_MANAGER.lock().unwrap().alloc()); - unsafe { - THREAD = Some(new); - } - THREAD_GUARD.with(|guard| guard.id.set(new.id)); - new - } - } else { - // This is split into 2 thread-local variables so that we can check whether the - // thread is initialized without having to register a thread-local destructor. - // - // This makes the fast path smaller. - thread_local! { static THREAD: Cell<Option<Thread>> = const { Cell::new(None) }; } - thread_local! { static THREAD_GUARD: ThreadGuard = const { ThreadGuard { id: Cell::new(0) } }; } - - // Guard to ensure the thread ID is released on thread exit. - struct ThreadGuard { - // We keep a copy of the thread ID in the ThreadGuard: we can't - // reliably access THREAD in our Drop impl due to the unpredictable - // order of TLS destructors. - id: Cell<usize>, - } - - impl Drop for ThreadGuard { - fn drop(&mut self) { - // Release the thread ID. Any further accesses to the thread ID - // will go through get_slow which will either panic or - // initialize a new ThreadGuard. - let _ = THREAD.try_with(|thread| thread.set(None)); - THREAD_ID_MANAGER.lock().unwrap().free(self.id.get()); - } - } - - /// Returns a thread ID for the current thread, allocating one if needed. - #[inline] - pub(crate) fn get() -> Thread { - THREAD.with(|thread| { - if let Some(thread) = thread.get() { - thread - } else { - get_slow(thread) - } - }) - } - - /// Out-of-line slow path for allocating a thread ID. - #[cold] - fn get_slow(thread: &Cell<Option<Thread>>) -> Thread { - let new = Thread::new(THREAD_ID_MANAGER.lock().unwrap().alloc()); - thread.set(Some(new)); - THREAD_GUARD.with(|guard| guard.id.set(new.id)); - new - } - } -} - -#[test] -fn test_thread() { - let thread = Thread::new(0); - assert_eq!(thread.id, 0); - assert_eq!(thread.bucket, 0); - assert_eq!(thread.bucket_size, 1); - assert_eq!(thread.index, 0); - - let thread = Thread::new(1); - assert_eq!(thread.id, 1); - assert_eq!(thread.bucket, 1); - assert_eq!(thread.bucket_size, 2); - assert_eq!(thread.index, 0); - - let thread = Thread::new(2); - assert_eq!(thread.id, 2); - assert_eq!(thread.bucket, 1); - assert_eq!(thread.bucket_size, 2); - assert_eq!(thread.index, 1); - - let thread = Thread::new(3); - assert_eq!(thread.id, 3); - assert_eq!(thread.bucket, 2); - assert_eq!(thread.bucket_size, 4); - assert_eq!(thread.index, 0); - - let thread = Thread::new(19); - assert_eq!(thread.id, 19); - assert_eq!(thread.bucket, 4); - assert_eq!(thread.bucket_size, 16); - assert_eq!(thread.index, 4); -} diff --git a/vendor/thread_local/src/unreachable.rs b/vendor/thread_local/src/unreachable.rs deleted file mode 100644 index db4d831a..00000000 --- a/vendor/thread_local/src/unreachable.rs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2017 Amanieu d'Antras -// -// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or -// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or -// http://opensource.org/licenses/MIT>, at your option. This file may not be -// copied, modified, or distributed except according to those terms. - -use std::hint::unreachable_unchecked; - -/// An extension trait for `Option<T>` providing unchecked unwrapping methods. -pub trait UncheckedOptionExt<T> { - /// Get the value out of this Option without checking for None. - unsafe fn unchecked_unwrap(self) -> T; - - /// Assert that this Option is a None to the optimizer. - unsafe fn unchecked_unwrap_none(self); -} - -/// An extension trait for `Result<T, E>` providing unchecked unwrapping methods. -pub trait UncheckedResultExt<T, E> { - /// Get the value out of this Result without checking for Err. - unsafe fn unchecked_unwrap_ok(self) -> T; - - /// Get the error out of this Result without checking for Ok. - unsafe fn unchecked_unwrap_err(self) -> E; -} - -impl<T> UncheckedOptionExt<T> for Option<T> { - unsafe fn unchecked_unwrap(self) -> T { - match self { - Some(x) => x, - None => unreachable_unchecked(), - } - } - - unsafe fn unchecked_unwrap_none(self) { - if self.is_some() { - unreachable_unchecked() - } - } -} - -impl<T, E> UncheckedResultExt<T, E> for Result<T, E> { - unsafe fn unchecked_unwrap_ok(self) -> T { - match self { - Ok(x) => x, - Err(_) => unreachable_unchecked(), - } - } - - unsafe fn unchecked_unwrap_err(self) -> E { - match self { - Ok(_) => unreachable_unchecked(), - Err(e) => e, - } - } -} |
