Skip to content

Commit

Permalink
Cull: add [[nodiscard]]
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Nov 29, 2024
1 parent 3083a05 commit 4be9acb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Cull.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ class Cull::DirectoryRef {
Directory &directory;

public:
[[nodiscard]]
explicit DirectoryRef(Directory &_directory) noexcept
:directory(_directory.Ref()) {}

struct Adopt {};

[[nodiscard]]
DirectoryRef(Adopt, Directory &_directory) noexcept
:directory(_directory) {}

Expand All @@ -43,10 +46,12 @@ class Cull::DirectoryRef {
DirectoryRef(const DirectoryRef &) = delete;
DirectoryRef &operator=(const DirectoryRef &) = delete;

[[nodiscard]]
Directory &operator*() const noexcept{
return directory;
}

[[nodiscard]]
Directory *operator->() const noexcept{
return &directory;
}
Expand All @@ -61,6 +66,7 @@ struct Cull::File final : IntrusiveTreeSetHook<> {

const std::string name;

[[nodiscard]]
File(Directory &_parent, std::string &&_name,
FileTime _time, const uint_least64_t _size) noexcept
:parent(_parent), time(_time), size(_size),
Expand Down Expand Up @@ -97,6 +103,7 @@ class Cull::StatItem : public IntrusiveListHook<> {
Co::InvokeTask invoke_task;

public:
[[nodiscard]]
StatItem(Cull &_cull, Directory &_directory, const char *_name) noexcept
:cull(_cull), directory(_directory), name(_name) {}

Expand All @@ -106,6 +113,7 @@ class Cull::StatItem : public IntrusiveListHook<> {
}

private:
[[nodiscard]]
Co::InvokeTask Run(Uring::Queue &uring);

void OnCompletion(std::exception_ptr error) noexcept {
Expand Down
1 change: 1 addition & 0 deletions src/Cull.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class Cull {
const FileTime discard_older_than;

public:
[[nodiscard]]
Cull(EventLoop &_event_loop, Uring::Queue &_uring,
FileDescriptor _dev_cachefiles, FileDescriptor root_fd,
std::size_t _cull_files, uint_least64_t _cull_bytes,
Expand Down

0 comments on commit 4be9acb

Please sign in to comment.