storage/nfs: optimize OpenFile()

This commit is contained in:
Max Kellermann
2024-05-15 21:46:38 +02:00
parent 9e8128ecb5
commit b64d01677b
5 changed files with 67 additions and 13 deletions

View File

@@ -31,6 +31,15 @@ public:
NFS_MAX_BUFFERED,
NFS_RESUME_AT) {}
NfsInputStream(NfsConnection &_connection, std::string_view _path,
Mutex &_mutex) noexcept
:NfsFileReader(_connection, _path),
AsyncInputStream(NfsFileReader::GetEventLoop(),
NfsFileReader::GetAbsoluteUri(),
_mutex,
NFS_MAX_BUFFERED,
NFS_RESUME_AT) {}
~NfsInputStream() override {
DeferClose();
}
@@ -225,3 +234,10 @@ const InputPlugin input_plugin_nfs = {
input_nfs_open,
nullptr
};
InputStreamPtr
OpenNfsInputStream(NfsConnection &connection, std::string_view path,
Mutex &mutex)
{
return std::make_unique<NfsInputStream>(connection, path, mutex);
}

View File

@@ -1,9 +1,17 @@
// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project
#ifndef MPD_INPUT_NFS_H
#define MPD_INPUT_NFS_H
#pragma once
#include "input/Ptr.hxx"
#include "thread/Mutex.hxx"
#include <string_view>
class NfsConnection;
extern const struct InputPlugin input_plugin_nfs;
#endif
InputStreamPtr
OpenNfsInputStream(NfsConnection &connection, std::string_view path,
Mutex &mutex);