From 952af0109a73901d38d8b60b3409d2a108d41d75 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Sat, 28 May 2022 09:08:18 +0100 Subject: [PATCH 1/5] bump scheduled-thread-pool --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index a6309279..cc5cc16c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,7 @@ crossbeam-utils = "0.8" num_cpus = "1.13" once_cell = "1.7" parking_lot = "0.12" -scheduled-thread-pool = "0.2.5" +scheduled-thread-pool = "0.2.6" smallvec = "1.8" tagptr = "0.2" thiserror = "1.0" From cb9bc3cf94d095e2a25411ddee58a5b105838450 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Sat, 28 May 2022 09:13:04 +0100 Subject: [PATCH 2/5] apply visibility changes --- Cargo.toml | 10 ++++++---- src/lib.rs | 6 +++--- src/sync/builder.rs | 1 + src/sync/cache.rs | 1 + src/sync/segment.rs | 1 + src/sync/value_initializer.rs | 2 +- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cc5cc16c..b6e989a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,9 @@ build = "build.rs" default = ["atomic64", "quanta"] # Enable this feature to use `moka::future::Cache`. -future = ["async-io", "async-lock", "futures-util"] +future = ["async-io", "async-lock", "futures-util", "crossbeam-epoch", "thiserror", "uuid"] + +sync = ["crossbeam-epoch", "thiserror", "uuid"] # Enable this feature to use **experimental** `moka::dash::Cache`. # Please note that the APIs for this feature will be frequently changed in next @@ -39,7 +41,7 @@ unstable-debug-counters = ["future"] [dependencies] crossbeam-channel = "0.5.4" -crossbeam-epoch = "0.8.2" +crossbeam-epoch = { version = "0.8.2", optional = true } crossbeam-utils = "0.8" num_cpus = "1.13" once_cell = "1.7" @@ -47,8 +49,8 @@ parking_lot = "0.12" scheduled-thread-pool = "0.2.6" smallvec = "1.8" tagptr = "0.2" -thiserror = "1.0" -uuid = { version = "0.8", features = ["v4"] } +thiserror = { version = "1.0", optional = true } +uuid = { version = "0.8", features = ["v4"], optional = true } # Opt-out serde and stable_deref_trait features # https://github.com/Manishearth/triomphe/pull/5 diff --git a/src/lib.rs b/src/lib.rs index 6227133c..2a3154b4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -165,14 +165,14 @@ pub mod dash; #[cfg(feature = "future")] #[cfg_attr(docsrs, doc(cfg(feature = "future")))] pub mod future; - +#[cfg(any(feature="sync", feature="future"))] pub mod sync; pub mod unsync; - +#[cfg(any(feature="sync", feature="future"))] pub(crate) mod cht; pub(crate) mod common; pub(crate) mod policy; - +#[cfg(any(feature="sync", feature="future"))] pub use common::error::PredicateError; pub use policy::Policy; diff --git a/src/sync/builder.rs b/src/sync/builder.rs index d5753efd..dff1e3e1 100644 --- a/src/sync/builder.rs +++ b/src/sync/builder.rs @@ -41,6 +41,7 @@ use std::{ /// // after 30 minutes (TTL) from the insert(). /// ``` /// +#[cfg(feature="sync")] #[must_use] pub struct CacheBuilder { max_capacity: Option, diff --git a/src/sync/cache.rs b/src/sync/cache.rs index 87af4fcd..3493f201 100644 --- a/src/sync/cache.rs +++ b/src/sync/cache.rs @@ -227,6 +227,7 @@ use std::{ /// [build-with-hasher-method]: ./struct.CacheBuilder.html#method.build_with_hasher /// [ahash-crate]: https://crates.io/crates/ahash /// +#[cfg(feature="sync")] pub struct Cache { base: BaseCache, value_initializer: Arc>, diff --git a/src/sync/segment.rs b/src/sync/segment.rs index 326a8439..e0d01a8f 100644 --- a/src/sync/segment.rs +++ b/src/sync/segment.rs @@ -24,6 +24,7 @@ use std::{ /// /// [cache-struct]: ./struct.Cache.html /// +#[cfg(feature="sync")] pub struct SegmentedCache { inner: Arc>, } diff --git a/src/sync/value_initializer.rs b/src/sync/value_initializer.rs index 154f4af8..fe035794 100644 --- a/src/sync/value_initializer.rs +++ b/src/sync/value_initializer.rs @@ -17,7 +17,7 @@ pub(crate) enum InitResult { ReadExisting(V), InitErr(Arc), } - +#[cfg(feature="sync")] pub(crate) struct ValueInitializer { // TypeId is the type ID of the concrete error type of generic type E in // try_init_or_read(). We use the type ID as a part of the key to ensure that From 3410c0460e95b76e69c570788c96f27455eee4a4 Mon Sep 17 00:00:00 2001 From: Milo <50248166+Milo123459@users.noreply.github.com> Date: Sat, 28 May 2022 09:41:00 +0100 Subject: [PATCH 3/5] fixes? --- src/common/error.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/common/error.rs b/src/common/error.rs index 7fa5a3d6..2c6ef3f1 100644 --- a/src/common/error.rs +++ b/src/common/error.rs @@ -2,6 +2,7 @@ /// [`Cache#invalidate_entries_if`][invalidate-if] method. /// /// [invalidate-if]: ./sync/struct.Cache.html#method.invalidate_entries_if +#[cfg(any(feature="sync", feature="future"))] #[derive(thiserror::Error, Debug)] pub enum PredicateError { /// This cache does not have a necessary configuration enabled to support From 264f048b6374ec15f642706cae035a0e21ba6770 Mon Sep 17 00:00:00 2001 From: Tatsuya Kawano Date: Sun, 29 May 2022 13:18:16 +0800 Subject: [PATCH 4/5] Introduce a new crate feature called `sync` - The `sync` feature: - It controls the availability of the `sync` module. (e.g. `sync::Cache` and `sync::SegmentedCache`) - It is enabled by default. - `future::Cache`: - The iterator type for `future::Cache` has been changed from `sync::Iter` to `future::Iter`. - The return type of `future::Cache::invalidate_entries_if` method has been changed from `Result` to `Result`. - Update the CI configurations for the `sync` feature. --- .circleci/config.yml | 2 +- .github/workflows/CI.yml | 22 +++++++++------ .github/workflows/CIQuantaDisabled.yml | 20 +++++++++----- .github/workflows/LinuxCrossCompileTest.yml | 4 +-- .github/workflows/Skeptic.yml | 10 +++---- Cargo.toml | 18 +++++++------ src/common.rs | 4 +-- src/common/concurrent.rs | 2 +- src/common/concurrent/thread_pool.rs | 8 +++--- src/common/deque.rs | 2 +- src/common/error.rs | 1 - src/common/time.rs | 2 +- src/common/time/clock_quanta.rs | 3 +-- src/future.rs | 30 +++++++++++++++++++++ src/future/cache.rs | 8 +++--- src/lib.rs | 9 ++++--- src/policy.rs | 4 +-- src/sync/builder.rs | 1 - src/sync/cache.rs | 1 - src/sync/segment.rs | 1 - src/sync/value_initializer.rs | 1 - src/sync_base/base_cache.rs | 2 +- src/sync_base/iter.rs | 2 +- 23 files changed, 98 insertions(+), 59 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 59cfc0e7..faa6b9b8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,7 +12,7 @@ jobs: --env RUSTFLAGS='--cfg circleci' \ xd009642/tarpaulin \ cargo tarpaulin -v \ - --features 'future, dash' \ + --features 'sync, future, dash' \ --ciserver circle-ci \ --coveralls ${COVERALLS_TOKEN} \ --timeout 600 \ diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 2a07527e..8627782e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -59,25 +59,31 @@ jobs: cargo update -p dashmap --precise 5.2.0 cargo update -p hashbrown --precise 0.11.2 - - name: Build (no features) + - name: Run tests (debug, sync feature) uses: actions-rs/cargo@v1 with: - command: build + command: test --features sync - - name: Run tests (release, no features) + - name: Run tests (release, sync feature) uses: actions-rs/cargo@v1 with: command: test - args: --release + args: --release --features sync - - name: Run tests (future feature) + - name: Run tests (future feature, but no sync feature) uses: actions-rs/cargo@v1 with: command: test - args: --features future + args: --no-default-features --features 'future, atomic64, quanta' - - name: Run tests (dash feature) + - name: Run tests (future and sync features) uses: actions-rs/cargo@v1 with: command: test - args: --features dash + args: --features 'future, sync' + + - name: Run tests (dash feature, but no sync feature) + uses: actions-rs/cargo@v1 + with: + command: test + args: --no-default-features --features 'dash, atomic64, quanta' diff --git a/.github/workflows/CIQuantaDisabled.yml b/.github/workflows/CIQuantaDisabled.yml index 78b7220f..21ed22fd 100644 --- a/.github/workflows/CIQuantaDisabled.yml +++ b/.github/workflows/CIQuantaDisabled.yml @@ -59,25 +59,31 @@ jobs: cargo update -p dashmap --precise 5.2.0 cargo update -p hashbrown --precise 0.11.2 - - name: Build (no quanta feature) + - name: Run tests (debug, but no quanta feature) uses: actions-rs/cargo@v1 with: - command: build - args: --no-default-features --features atomic64 + command: test + args: --no-default-features --features 'sync, atomic64' - - name: Run tests (release, no quanta feature) + - name: Run tests (release, but no quanta feature) uses: actions-rs/cargo@v1 with: command: test - args: --release --no-default-features --features atomic64 + args: --release --no-default-features --features 'sync, atomic64' - - name: Run tests (future feature, but no quanta feature) + - name: Run tests (future feature, but no quanta and sync features) uses: actions-rs/cargo@v1 with: command: test args: --no-default-features --features 'future, atomic64' - - name: Run tests (dash feature, but no quanta feature) + - name: Run tests (future feature, but no quanta feature) + uses: actions-rs/cargo@v1 + with: + command: test + args: --no-default-features --features 'sync, future, atomic64' + + - name: Run tests (dash feature, but no quanta and sync features) uses: actions-rs/cargo@v1 with: command: test diff --git a/.github/workflows/LinuxCrossCompileTest.yml b/.github/workflows/LinuxCrossCompileTest.yml index ebe90a96..64840b71 100644 --- a/.github/workflows/LinuxCrossCompileTest.yml +++ b/.github/workflows/LinuxCrossCompileTest.yml @@ -59,12 +59,12 @@ jobs: with: command: clean - - name: Run tests (no features) + - name: Run tests (sync feature) uses: actions-rs/cargo@v1 with: use-cross: true command: test - args: --release --target ${{ matrix.platform.target }} ${{ matrix.platform.cargo-opts }} + args: --release --features sync --target ${{ matrix.platform.target }} ${{ matrix.platform.cargo-opts }} - name: Run tests (future feature) uses: actions-rs/cargo@v1 diff --git a/.github/workflows/Skeptic.yml b/.github/workflows/Skeptic.yml index 7c021aca..686add75 100644 --- a/.github/workflows/Skeptic.yml +++ b/.github/workflows/Skeptic.yml @@ -50,23 +50,23 @@ jobs: uses: actions-rs/cargo@v1 with: command: test - args: --release --features 'future, dash' + args: --release --features 'sync, future, dash' env: RUSTFLAGS: '--cfg skeptic' - - name: Run tests (future and dash, without atomic64) + - name: Run tests (sync, future and dash, without atomic64 and quanta) uses: actions-rs/cargo@v1 with: command: test - args: --release --no-default-features --features 'future, dash' + args: --release --no-default-features --features 'sync, future, dash' env: RUSTFLAGS: '--cfg skeptic' - - name: Run compile error tests (future and dash features, trybuild) + - name: Run compile error tests (sync, future and dash features, trybuild) uses: actions-rs/cargo@v1 if: ${{ matrix.rust == 'stable' }} with: command: test - args: ui_trybuild --release --features 'future, dash' + args: ui_trybuild --release --features 'sync, future, dash' env: RUSTFLAGS: '--cfg trybuild' diff --git a/Cargo.toml b/Cargo.toml index 29c26770..71f625d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,13 +16,15 @@ exclude = [".circleci", ".devcontainer", ".github", ".gitpod.yml", ".vscode"] build = "build.rs" [features] -default = ["atomic64", "quanta"] - -# Enable this feature to use `moka::future::Cache`. -future = ["async-io", "async-lock", "futures-util", "crossbeam-epoch", "thiserror", "uuid"] +default = ["sync", "atomic64", "quanta"] +# This feature is enabled by default. Disable it when you do not need +# `moka::sync::{Cache, SegmentedCache}` sync = ["crossbeam-epoch", "thiserror", "uuid"] +# Enable this feature to use `moka::future::Cache`. +future = ["crossbeam-epoch", "thiserror", "uuid", "async-io", "async-lock", "futures-util"] + # Enable this feature to use **experimental** `moka::dash::Cache`. # Please note that the APIs for this feature will be frequently changed in next # few releases. @@ -41,7 +43,6 @@ unstable-debug-counters = ["future"] [dependencies] crossbeam-channel = "0.5.4" -crossbeam-epoch = { version = "0.8.2", optional = true } crossbeam-utils = "0.8" num_cpus = "1.13" once_cell = "1.7" @@ -49,15 +50,16 @@ parking_lot = "0.12" scheduled-thread-pool = "0.2.6" smallvec = "1.8" tagptr = "0.2" -thiserror = { version = "1.0", optional = true } -uuid = { version = "0.8", features = ["v4"], optional = true } # Opt-out serde and stable_deref_trait features # https://github.com/Manishearth/triomphe/pull/5 triomphe = { version = "0.1", default-features = false } -# Optional dependencies (quanta, enabled by default) +# Optional dependencies (enabled by default) +crossbeam-epoch = { version = "0.8.2", optional = true } quanta = { version = "0.10.0", optional = true } +thiserror = { version = "1.0", optional = true } +uuid = { version = "0.8", features = ["v4"], optional = true } # Optional dependencies (dashmap) dashmap = { version = "5.2", optional = true } diff --git a/src/common.rs b/src/common.rs index 0e3fe59d..47d49927 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,9 +1,9 @@ use std::convert::TryInto; -// #[cfg(any(feature = "sync", feature = "future", feature = "dash"))] +#[cfg(any(feature = "sync", feature = "future", feature = "dash"))] pub(crate) mod concurrent; -// #[cfg(any(feature = "sync", feature = "future"))] +#[cfg(any(feature = "sync", feature = "future"))] pub(crate) mod error; pub(crate) mod builder_utils; diff --git a/src/common/concurrent.rs b/src/common/concurrent.rs index 2deefc8e..34668061 100644 --- a/src/common/concurrent.rs +++ b/src/common/concurrent.rs @@ -77,7 +77,7 @@ impl KeyDate { &self.key } - // #[cfg(any(feature = "sync", feature = "future"))] + #[cfg(any(feature = "sync", feature = "future"))] pub(crate) fn last_modified(&self) -> Option { self.entry_info.last_modified() } diff --git a/src/common/concurrent/thread_pool.rs b/src/common/concurrent/thread_pool.rs index 9baf7fe8..cb121c40 100644 --- a/src/common/concurrent/thread_pool.rs +++ b/src/common/concurrent/thread_pool.rs @@ -5,11 +5,11 @@ use std::{collections::HashMap, sync::Arc}; static REGISTRY: Lazy = Lazy::new(ThreadPoolRegistry::default); -#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] -// #[cfg_attr(any(feature = "sync", feature = "future"), derive(Debug))] +#[derive(Clone, Copy, Hash, PartialEq, Eq)] +#[cfg_attr(any(feature = "sync", feature = "future"), derive(Debug))] pub(crate) enum PoolName { Housekeeper, - // #[cfg(any(feature = "sync", feature = "future"))] + #[cfg(any(feature = "sync", feature = "future"))] Invalidator, } @@ -17,7 +17,7 @@ impl PoolName { fn thread_name_template(&self) -> &'static str { match self { PoolName::Housekeeper => "moka-housekeeper-{}", - // #[cfg(any(feature = "sync", feature = "future"))] + #[cfg(any(feature = "sync", feature = "future"))] PoolName::Invalidator => "moka-invalidator-{}", } } diff --git a/src/common/deque.rs b/src/common/deque.rs index 01e34687..c0c2115c 100644 --- a/src/common/deque.rs +++ b/src/common/deque.rs @@ -116,7 +116,7 @@ impl Deque { self.region } - // #[cfg(any(test, feature = "sync", feature = "future"))] + #[cfg(any(test, feature = "sync", feature = "future"))] pub(crate) fn len(&self) -> usize { self.len } diff --git a/src/common/error.rs b/src/common/error.rs index 2c6ef3f1..7fa5a3d6 100644 --- a/src/common/error.rs +++ b/src/common/error.rs @@ -2,7 +2,6 @@ /// [`Cache#invalidate_entries_if`][invalidate-if] method. /// /// [invalidate-if]: ./sync/struct.Cache.html#method.invalidate_entries_if -#[cfg(any(feature="sync", feature="future"))] #[derive(thiserror::Error, Debug)] pub enum PredicateError { /// This cache does not have a necessary configuration enabled to support diff --git a/src/common/time.rs b/src/common/time.rs index 4f51258b..163955d2 100644 --- a/src/common/time.rs +++ b/src/common/time.rs @@ -7,7 +7,7 @@ pub(crate) mod clock; pub(crate) use clock::Clock; #[cfg(test)] -// #[cfg(all(test, feature = "sync"))] +#[cfg(all(test, feature = "sync"))] pub(crate) use clock::Mock; /// a wrapper type over Instant to force checked additions and prevent diff --git a/src/common/time/clock_quanta.rs b/src/common/time/clock_quanta.rs index 6bb71ec9..b26f04df 100644 --- a/src/common/time/clock_quanta.rs +++ b/src/common/time/clock_quanta.rs @@ -1,6 +1,5 @@ pub(crate) type Clock = quanta::Clock; pub(crate) type Instant = quanta::Instant; -#[cfg(test)] -// #[cfg(all(test, feature = "sync"))] +#[cfg(all(test, feature = "sync"))] pub(crate) type Mock = quanta::Mock; diff --git a/src/future.rs b/src/future.rs index 3794cddc..04319ccf 100644 --- a/src/future.rs +++ b/src/future.rs @@ -3,6 +3,8 @@ //! //! To use this module, enable a crate feature called "future". +use std::{hash::Hash, sync::Arc}; + mod builder; mod cache; mod value_initializer; @@ -12,6 +14,34 @@ pub use { cache::{BlockingOp, Cache}, }; +/// The type of the unique ID to identify a predicate used by +/// [`Cache#invalidate_entries_if`][invalidate-if] method. +/// +/// A `PredicateId` is a `String` of UUID (version 4). +/// +/// [invalidate-if]: ./struct.Cache.html#method.invalidate_entries_if +pub type PredicateId = String; + +pub struct Iter<'i, K, V>(crate::sync_base::iter::Iter<'i, K, V>); + +impl<'i, K, V> Iter<'i, K, V> { + pub(crate) fn new(inner: crate::sync_base::iter::Iter<'i, K, V>) -> Self { + Self(inner) + } +} + +impl<'i, K, V> Iterator for Iter<'i, K, V> +where + K: Eq + Hash + Send + Sync + 'static, + V: Clone + Send + Sync + 'static, +{ + type Item = (Arc, V); + + fn next(&mut self) -> Option { + self.0.next() + } +} + /// Provides extra methods that will be useful for testing. pub trait ConcurrentCacheExt { /// Performs any pending maintenance operations needed by the cache. diff --git a/src/future/cache.rs b/src/future/cache.rs index 68d85cd4..1ebe432b 100644 --- a/src/future/cache.rs +++ b/src/future/cache.rs @@ -1,6 +1,6 @@ use super::{ value_initializer::{InitResult, ValueInitializer}, - CacheBuilder, ConcurrentCacheExt, + CacheBuilder, ConcurrentCacheExt, Iter, PredicateId, }; use crate::{ common::concurrent::{ @@ -8,7 +8,6 @@ use crate::{ housekeeper::InnerSync, Weigher, WriteOp, }, - sync::{Iter, PredicateId}, sync_base::base_cache::{BaseCache, HouseKeeperArc}, Policy, PredicateError, }; @@ -881,9 +880,10 @@ where /// ``` /// pub fn iter(&self) -> Iter<'_, K, V> { - use crate::sync_base::iter::ScanningGet; + use crate::sync_base::iter::{Iter as InnerIter, ScanningGet}; - Iter::with_single_cache_segment(&self.base, self.base.num_cht_segments()) + let inner = InnerIter::with_single_cache_segment(&self.base, self.base.num_cht_segments()); + Iter::new(inner) } /// Returns a `BlockingOp` for this cache. It provides blocking diff --git a/src/lib.rs b/src/lib.rs index 72e4a1b5..b379a61b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -162,7 +162,7 @@ pub(crate) mod common; pub(crate) mod policy; pub mod unsync; -// #[cfg(any(feature = "sync", feature = "future"))] +#[cfg(any(feature = "sync", feature = "future"))] pub(crate) mod cht; #[cfg(feature = "dash")] @@ -173,13 +173,14 @@ pub mod dash; #[cfg_attr(docsrs, doc(cfg(feature = "future")))] pub mod future; -// #[cfg(feature = "sync")] +#[cfg(feature = "sync")] +#[cfg_attr(docsrs, doc(cfg(feature = "sync")))] pub mod sync; -// #[cfg(any(feature = "sync", feature = "future"))] +#[cfg(any(feature = "sync", feature = "future"))] pub(crate) mod sync_base; -// #[cfg(any(feature = "sync", feature = "future"))] +#[cfg(any(feature = "sync", feature = "future"))] pub use common::error::PredicateError; pub use policy::Policy; diff --git a/src/policy.rs b/src/policy.rs index 4a1d49e4..2c2212e2 100644 --- a/src/policy.rs +++ b/src/policy.rs @@ -29,7 +29,7 @@ impl Policy { self.max_capacity } - // #[cfg(feature = "sync")] + #[cfg(feature = "sync")] pub(crate) fn set_max_capacity(&mut self, capacity: Option) { self.max_capacity = capacity; } @@ -39,7 +39,7 @@ impl Policy { self.num_segments } - // #[cfg(feature = "sync")] + #[cfg(feature = "sync")] pub(crate) fn set_num_segments(&mut self, num: usize) { self.num_segments = num; } diff --git a/src/sync/builder.rs b/src/sync/builder.rs index 319493f6..8e284f28 100644 --- a/src/sync/builder.rs +++ b/src/sync/builder.rs @@ -41,7 +41,6 @@ use std::{ /// // after 30 minutes (TTL) from the insert(). /// ``` /// -#[cfg(feature="sync")] #[must_use] pub struct CacheBuilder { max_capacity: Option, diff --git a/src/sync/cache.rs b/src/sync/cache.rs index f57b9e31..df8a81c4 100644 --- a/src/sync/cache.rs +++ b/src/sync/cache.rs @@ -236,7 +236,6 @@ use std::{ /// [build-with-hasher-method]: ./struct.CacheBuilder.html#method.build_with_hasher /// [ahash-crate]: https://crates.io/crates/ahash /// -#[cfg(feature="sync")] pub struct Cache { base: BaseCache, value_initializer: Arc>, diff --git a/src/sync/segment.rs b/src/sync/segment.rs index 76eeeb69..c4417754 100644 --- a/src/sync/segment.rs +++ b/src/sync/segment.rs @@ -24,7 +24,6 @@ use std::{ /// /// [cache-struct]: ./struct.Cache.html /// -#[cfg(feature="sync")] pub struct SegmentedCache { inner: Arc>, } diff --git a/src/sync/value_initializer.rs b/src/sync/value_initializer.rs index fe035794..2685fd8a 100644 --- a/src/sync/value_initializer.rs +++ b/src/sync/value_initializer.rs @@ -17,7 +17,6 @@ pub(crate) enum InitResult { ReadExisting(V), InitErr(Arc), } -#[cfg(feature="sync")] pub(crate) struct ValueInitializer { // TypeId is the type ID of the concrete error type of generic type E in // try_init_or_read(). We use the type ID as a part of the key to ensure that diff --git a/src/sync_base/base_cache.rs b/src/sync_base/base_cache.rs index 1876fded..dd6e7e6a 100644 --- a/src/sync_base/base_cache.rs +++ b/src/sync_base/base_cache.rs @@ -1,6 +1,7 @@ use super::{ invalidator::{GetOrRemoveEntry, InvalidationResult, Invalidator, KeyDateLite, PredicateFun}, iter::ScanningGet, + PredicateId, }; use crate::{ @@ -23,7 +24,6 @@ use crate::{ time::{CheckedTimeOps, Clock, Instant}, CacheRegion, }, - sync::PredicateId, Policy, PredicateError, }; diff --git a/src/sync_base/iter.rs b/src/sync_base/iter.rs index 7110df46..c52d72d4 100644 --- a/src/sync_base/iter.rs +++ b/src/sync_base/iter.rs @@ -40,7 +40,7 @@ impl<'i, K, V> Iter<'i, K, V> { } } - // #[cfg(feature = "sync")] + #[cfg(feature = "sync")] pub(crate) fn with_multiple_cache_segments( cache_segments: Box<[&'i dyn ScanningGet]>, num_cht_segments: usize, From abdace208e51d81d87a77add0034edb3d2b7e33c Mon Sep 17 00:00:00 2001 From: Tatsuya Kawano Date: Sun, 29 May 2022 13:29:04 +0800 Subject: [PATCH 5/5] Fix a CI job --- .github/workflows/CI.yml | 3 ++- src/sync/value_initializer.rs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8627782e..97f9d654 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -62,7 +62,8 @@ jobs: - name: Run tests (debug, sync feature) uses: actions-rs/cargo@v1 with: - command: test --features sync + command: test + args: --features sync - name: Run tests (release, sync feature) uses: actions-rs/cargo@v1 diff --git a/src/sync/value_initializer.rs b/src/sync/value_initializer.rs index 2685fd8a..154f4af8 100644 --- a/src/sync/value_initializer.rs +++ b/src/sync/value_initializer.rs @@ -17,6 +17,7 @@ pub(crate) enum InitResult { ReadExisting(V), InitErr(Arc), } + pub(crate) struct ValueInitializer { // TypeId is the type ID of the concrete error type of generic type E in // try_init_or_read(). We use the type ID as a part of the key to ensure that