userver: ydb::DistLockedWorker Class Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
ydb::DistLockedWorker Class Referencefinal

Your opinion will help to improve our service

Leave a feedback >

#include <userver/ydb/dist_lock/worker.hpp>

Detailed Description

A high-level primitive that perpetually tries to acquire a distributed lock and runs user callback in a separate task while the lock is held. Cancels the task when the lock is lost.

Definition at line 28 of file worker.hpp.

Public Types

using Callback = std::function<void()>
 

Public Member Functions

 DistLockedWorker (engine::TaskProcessor &task_processor, std::shared_ptr< CoordinationClient > coordination_client, std::string_view coordination_node, std::string_view semaphore_name, DistLockSettings settings, Callback callback)
 
void Start ()
 
void Stop () noexcept
 
void RunOnce ()
 Run the callback once under distlock, useful in tests.
 
bool OwnsLock () const noexcept
 

Member Typedef Documentation

◆ Callback

using ydb::DistLockedWorker::Callback = std::function<void()>

Definition at line 30 of file worker.hpp.

Member Function Documentation

◆ RunOnce()

void ydb::DistLockedWorker::RunOnce ( )

Run the callback once under distlock, useful in tests.

Warning
Must not be run alongside a normal task launched via Start.

The documentation for this class was generated from the following file: