diff options
author | udovichenko-r <rvu@ydb.tech> | 2022-09-14 17:39:59 +0300 |
---|---|---|
committer | udovichenko-r <rvu@ydb.tech> | 2022-09-14 17:39:59 +0300 |
commit | 1aa4ac536eea700d238b4e6142dbf58dc3bb5434 (patch) | |
tree | 27c0eb55930571bed6e539cd3484575488c9d5ee | |
parent | 332da01f2cfe1a99b6b7bfeda9ebe3b0a39a7112 (diff) | |
download | ydb-1aa4ac536eea700d238b4e6142dbf58dc3bb5434.tar.gz |
[yt provider] Use rwlock
-rw-r--r-- | ydb/library/yql/utils/threading/async_queue.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/ydb/library/yql/utils/threading/async_queue.h b/ydb/library/yql/utils/threading/async_queue.h index 173927a894..3dd75b9e08 100644 --- a/ydb/library/yql/utils/threading/async_queue.h +++ b/ydb/library/yql/utils/threading/async_queue.h @@ -7,7 +7,7 @@ #include <util/generic/ptr.h> #include <util/generic/function.h> #include <util/system/guard.h> -#include <util/system/mutex.h> +#include <util/system/rwlock.h> #include <exception> @@ -20,18 +20,18 @@ public: static TPtr Make(size_t numThreads, const TString& poolName); void Stop() { - with_lock(Lock_) { - if (MtpQueue_) { - MtpQueue_->Stop(); - MtpQueue_.Destroy(); - } + auto guard = TWriteGuard(Lock_); + if (MtpQueue_) { + MtpQueue_->Stop(); + MtpQueue_.Destroy(); } } template <typename TCallable> [[nodiscard]] ::NThreading::TFuture<::NThreading::TFutureType<::TFunctionResult<TCallable>>> Async(TCallable&& func) { - with_lock(Lock_) { + { + auto guard = TReadGuard(Lock_); if (MtpQueue_) { return ::NThreading::Async(std::move(func), *MtpQueue_); } @@ -44,7 +44,7 @@ private: TAsyncQueue(size_t numThreads, const TString& poolName); private: - TMutex Lock_; + TRWMutex Lock_; THolder<IThreadPool> MtpQueue_; }; |