Rayon uses a singleton global pool. By default it's set to a regular spawn handler with number of logical CPU cores, but it can be overridden by Rust applications to customize number of threads, spawn handlers, exit handlers and other options. Such customization should be usually done at the app level, because if a single library initialises the global pool, then Rayon will prevent any further overrides and they will error out. This can cause conflicts between libraries or library and user code and make them impossible to use together. Hence, I've removed the `threads` option from the `Options` struct and instead moved initialisation to the CLI part of the codebase (main.rs). Users of the library that didn't depend on custom `threads` number can keep using it as before - they'll still get same number of threads as number of logical CPU cores, while users who need fine-tuning, can do that by customizing rayon pool themselves at the top level of the app. Note: another alternative to keep the option could've been to use `ThreadPoolBuilder::build` + `ThreadPool::install` to use a local pool just within OxiPNG, but that would ignore any customizations made by users in top-level pool and would prevent usage on targets that require custom spawn handlers like WebAssembly. As such, I've decided to avoid it. Co-authored-by: Josh Holmer <jholmer.in@gmail.com>
75 lines
1.4 KiB
TOML
75 lines
1.4 KiB
TOML
[package]
|
|
authors = ["Joshua Holmer <jholmer.in@gmail.com>"]
|
|
categories = [
|
|
"command-line-utilities",
|
|
"compression",
|
|
]
|
|
description = "A lossless PNG compression optimizer"
|
|
documentation = "https://docs.rs/oxipng"
|
|
edition = "2018"
|
|
exclude = [
|
|
"tests/*",
|
|
"bench/*",
|
|
]
|
|
homepage = "https://github.com/shssoichiro/oxipng"
|
|
license = "MIT"
|
|
name = "oxipng"
|
|
repository = "https://github.com/shssoichiro/oxipng"
|
|
version = "2.3.0"
|
|
|
|
[badges]
|
|
travis-ci = { repository = "shssoichiro/oxipng", branch = "master" }
|
|
maintenance = { status = "actively-developed" }
|
|
|
|
[[bin]]
|
|
doc = false
|
|
name = "oxipng"
|
|
path = "src/main.rs"
|
|
required-features = ["binary"]
|
|
|
|
[dependencies]
|
|
bit-vec = "^0.6.0"
|
|
byteorder = "^1.0.0"
|
|
crc = "^1.2.0"
|
|
itertools = "^0.9.0"
|
|
zopfli = "^0.4.0"
|
|
miniz_oxide = "0.3"
|
|
rgb = "0.8.11"
|
|
indexmap = { version = "1.3.2", features = ["rayon"] }
|
|
libdeflater = "0.2.0"
|
|
|
|
[dependencies.rayon]
|
|
optional = true
|
|
version = "^1.0.0"
|
|
|
|
[dependencies.clap]
|
|
optional = true
|
|
version = "^2.10.0"
|
|
|
|
[dependencies.wild]
|
|
optional = true
|
|
version = "2.0.0"
|
|
|
|
[target.'cfg(any(target_arch = "x86_64", target_arch = "aarch64"))'.dependencies]
|
|
cloudflare-zlib = "^0.2.2"
|
|
|
|
[dependencies.image]
|
|
default-features = false
|
|
features = ["png"]
|
|
version = "0.23"
|
|
|
|
[features]
|
|
binary = [
|
|
"clap",
|
|
"wild",
|
|
]
|
|
default = ["binary", "parallel"]
|
|
parallel = ["rayon"]
|
|
|
|
[lib]
|
|
name = "oxipng"
|
|
path = "src/lib.rs"
|
|
[profile.dev]
|
|
opt-level = 2
|
|
[profile.release]
|
|
lto = true
|