mirror of https://github.com/xacrimon/dashmap
Hide shards and determine_map behind the raw-api feature.
This commit is contained in:
parent
3021d1aa23
commit
b72b8419de
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "dashmap"
|
||||
version = "3.0.2"
|
||||
version = "3.0.3"
|
||||
authors = ["Acrimon <joel.wejdenstal@gmail.com>"]
|
||||
edition = "2018"
|
||||
license = "MIT"
|
||||
|
@ -14,6 +14,7 @@ categories = ["concurrency", "algorithms", "data-structures"]
|
|||
|
||||
[features]
|
||||
nightly = ["parking_lot/nightly"]
|
||||
raw-api = []
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = "0.3.0"
|
||||
|
@ -46,4 +47,8 @@ harness = false
|
|||
parking_lot = "0.10.0"
|
||||
num_cpus = "1.11.1"
|
||||
fxhash = "0.2.1"
|
||||
serde = { version = "~1.0.24", optional = true, features = ["derive"] }
|
||||
serde = { version = "1.0.104", optional = true, features = ["derive"] }
|
||||
cfg-if = "0.1.10"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
|
|
@ -24,6 +24,8 @@ If you have any suggestions or tips do not hesitate to open an issue or a PR.
|
|||
|
||||
- `serde` - Enables serde support.
|
||||
|
||||
- `raw-api` - Enables the unstable raw-shard api.
|
||||
|
||||
## Contributing
|
||||
|
||||
DashMap is gladly accepts contributions!
|
||||
|
|
15
src/lib.rs
15
src/lib.rs
|
@ -19,6 +19,7 @@ use std::iter::FromIterator;
|
|||
use std::ops::{BitAnd, BitOr, Shl, Shr, Sub};
|
||||
use t::Map;
|
||||
use util::SharedValue;
|
||||
use cfg_if::cfg_if;
|
||||
|
||||
type HashMap<K, V> = std::collections::HashMap<K, SharedValue<V>, FxBuildHasher>;
|
||||
|
||||
|
@ -114,9 +115,13 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap<K, V> {
|
|||
/// let map = DashMap::<(), ()>::new();
|
||||
/// println!("Amount of shards: {}", map.shards().len());
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn shards(&self) -> &[RwLock<HashMap<K, V>>] {
|
||||
&self.shards
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "raw-api")] {
|
||||
#[inline]
|
||||
pub fn shards(&self) -> &[RwLock<HashMap<K, V>>] {
|
||||
&self.shards
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Finds which shard a certain key is stored in.
|
||||
|
@ -132,7 +137,9 @@ impl<'a, K: 'a + Eq + Hash, V: 'a> DashMap<K, V> {
|
|||
/// println!("coca-cola is stored in shard: {}", map.determine_map("coca-cola"));
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn determine_map<Q>(&self, key: &Q) -> usize
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "raw-api")] { pub }
|
||||
} fn determine_map<Q>(&self, key: &Q) -> usize
|
||||
where
|
||||
K: Borrow<Q>,
|
||||
Q: Hash + Eq + ?Sized,
|
||||
|
|
Loading…
Reference in New Issue