diff options
Diffstat (limited to 'src/mongo/util/read_through_cache.cpp')
-rw-r--r-- | src/mongo/util/read_through_cache.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/mongo/util/read_through_cache.cpp b/src/mongo/util/read_through_cache.cpp index a46f93c326f..877421fac9e 100644 --- a/src/mongo/util/read_through_cache.cpp +++ b/src/mongo/util/read_through_cache.cpp @@ -31,9 +31,14 @@ #include "mongo/util/read_through_cache.h" +#include "mongo/db/client.h" + namespace mongo { -ReadThroughCacheBase::ReadThroughCacheBase(Mutex& mutex) : _cacheWriteMutex(mutex) {} +ReadThroughCacheBase::ReadThroughCacheBase(Mutex& mutex, + ServiceContext* service, + ThreadPoolInterface& threadPool) + : _serviceContext(service), _threadPool(threadPool), _cacheWriteMutex(mutex) {} ReadThroughCacheBase::~ReadThroughCacheBase() = default; @@ -42,6 +47,14 @@ OID ReadThroughCacheBase::getCacheGeneration() const { return _fetchGeneration; } +void ReadThroughCacheBase::_asyncWork(WorkWithOpContext work) { + _threadPool.schedule([this, work = std::move(work)](Status status) { + ThreadClient tc(_serviceContext); + auto opCtxHolder = tc->makeOperationContext(); + work(opCtxHolder.get()); + }); +} + void ReadThroughCacheBase::_updateCacheGeneration(const CacheGuard&) { _fetchGeneration = OID::gen(); } |