Sha256: c18bb5d7975ac89ece91288cb0fbf16fdf847ecb5fe5a3b6317970fe1179788f

Contents?: true

Size: 1.1 KB

Versions: 34

Compression:

Stored size: 1.1 KB

Contents

// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)

#pragma once

// periodic worker thread - periodically executes the given callback function.
//
// RAII over the owned thread:
//    creates the thread on construction.
//    stops and joins the thread on destruction (if the thread is executing a callback, wait for it to finish first).

#include <chrono>
#include <condition_variable>
#include <functional>
#include <mutex>
#include <thread>
namespace spdlog {
namespace details {

class SPDLOG_API periodic_worker
{
public:
    periodic_worker(const std::function<void()> &callback_fun, std::chrono::seconds interval);
    periodic_worker(const periodic_worker &) = delete;
    periodic_worker &operator=(const periodic_worker &) = delete;
    // stop the worker thread and join it
    ~periodic_worker();

private:
    bool active_;
    std::thread worker_thread_;
    std::mutex mutex_;
    std::condition_variable cv_;
};
} // namespace details
} // namespace spdlog

#ifdef SPDLOG_HEADER_ONLY
#include "periodic_worker-inl.h"
#endif

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
couchbase-3.2.0-universal-darwin-20 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.2.0 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.1.1 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.1.1-universal-darwin-20 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.1.0 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.0.3 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.0.3-universal-darwin-20 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.0.2 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.0.1-universal-darwin-19 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.0.1 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.0.0-universal-darwin-19 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.0.0 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.0.0.beta.1-universal-darwin-19 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.0.0.beta.1 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.0.0.alpha.5-x86_64-linux ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.0.0.alpha.5-universal-darwin-19 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.0.0.alpha.5-x86_64-darwin-19 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.0.0.alpha.5 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.0.0.alpha.4-x86_64-linux ext/third_party/spdlog/include/spdlog/details/periodic_worker.h
couchbase-3.0.0.alpha.4-x86_64-darwin-19 ext/third_party/spdlog/include/spdlog/details/periodic_worker.h