1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-04 05:56:02 +00:00
transmission/libtransmission/watchdir.h
Charles Kerr 162035a653
fix: minor recent clang warnings (#4111)
* refactor: fix modernize-use-default-member-init warning in session-thread.cc

* refactor: fix readability-named-parameter warning in session-thread.cc

* refactor: fix clang-diagnostic-unused-function warning for isSupportedSocket()

* refactor: fix clang-analyzer-deadcode.DeadStores warning in buildHandshakeMessage()

* chore: fix readability-identifier-naming warning for tr_session::session_mutex_

* chore: fix readability-identifier-naming warning for Watchdir::generic_rescan_interval_

* chore: fix readability-identifier-naming warning for __tr_current_time
2022-11-07 11:48:26 -06:00

70 lines
1.8 KiB
C++

// This file Copyright 2015-2022 Mnemosyne LLC.
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
// or any future license endorsed by Mnemosyne LLC.
// License text can be found in the licenses/ folder.
#pragma once
#include <chrono>
#include <functional>
#include <memory>
#include <string_view>
extern "C"
{
struct event_base;
}
namespace libtransmission
{
class TimerMaker;
class Watchdir
{
public:
Watchdir() = default;
virtual ~Watchdir() = default;
Watchdir(Watchdir&&) = delete;
Watchdir(Watchdir const&) = delete;
Watchdir& operator=(Watchdir&&) = delete;
Watchdir& operator=(Watchdir const&) = delete;
[[nodiscard]] virtual std::string_view dirname() const noexcept = 0;
enum class Action
{
Done,
Retry
};
using Callback = std::function<Action(std::string_view dirname, std::string_view basename)>;
[[nodiscard]] static auto genericRescanInterval() noexcept
{
return generic_rescan_interval;
}
static void setGenericRescanInterval(std::chrono::milliseconds interval) noexcept
{
generic_rescan_interval = interval;
}
[[nodiscard]] static std::unique_ptr<Watchdir> create(
std::string_view dirname,
Callback callback,
libtransmission::TimerMaker& timer_maker,
struct event_base* evbase);
[[nodiscard]] static std::unique_ptr<Watchdir> createGeneric(
std::string_view dirname,
Callback callback,
libtransmission::TimerMaker& timer_maker,
std::chrono::milliseconds rescan_interval = generic_rescan_interval);
private:
static constexpr std::chrono::milliseconds DefaultGenericRescanInterval{ 1000 };
static std::chrono::milliseconds generic_rescan_interval;
};
} // namespace libtransmission