lib/nfs/{FileReader,Glue}: pass EventLoop&

Eliminate dependency on io_thread_get().
This commit is contained in:
Max Kellermann
2017-01-25 22:58:13 +01:00
parent 4140e9b857
commit 611ce6e756
7 changed files with 17 additions and 13 deletions

View File

@@ -23,7 +23,6 @@
#include "Base.hxx"
#include "Connection.hxx"
#include "event/Call.hxx"
#include "IOThread.hxx"
#include "util/StringCompare.hxx"
#include <utility>
@@ -33,8 +32,8 @@
#include <fcntl.h>
#include <sys/stat.h>
NfsFileReader::NfsFileReader()
:DeferredMonitor(io_thread_get()), state(State::INITIAL)
NfsFileReader::NfsFileReader(EventLoop &event_loop)
:DeferredMonitor(event_loop), state(State::INITIAL)
{
}
@@ -86,7 +85,7 @@ NfsFileReader::CancelOrClose()
void
NfsFileReader::DeferClose()
{
BlockingCall(io_thread_get(), [this](){ Close(); });
BlockingCall(GetEventLoop(), [this](){ Close(); });
}
void

View File

@@ -64,9 +64,11 @@ class NfsFileReader : NfsLease, NfsCallback, DeferredMonitor {
nfsfh *fh;
public:
NfsFileReader();
NfsFileReader(EventLoop &event_loop);
~NfsFileReader();
using DeferredMonitor::GetEventLoop;
void Close();
void DeferClose();

View File

@@ -20,7 +20,6 @@
#include "config.h"
#include "Glue.hxx"
#include "Manager.hxx"
#include "IOThread.hxx"
#include "event/Call.hxx"
#include "util/Manual.hxx"
@@ -30,12 +29,12 @@ static Manual<NfsManager> nfs_glue;
static unsigned in_use;
void
nfs_init()
nfs_init(EventLoop &event_loop)
{
if (in_use++ > 0)
return;
nfs_glue.Construct(io_thread_get());
nfs_glue.Construct(event_loop);
}
void
@@ -46,14 +45,13 @@ nfs_finish()
if (--in_use > 0)
return;
BlockingCall(io_thread_get(), [](){ nfs_glue.Destruct(); });
BlockingCall(nfs_glue->GetEventLoop(), [](){ nfs_glue.Destruct(); });
}
NfsConnection &
nfs_get_connection(const char *server, const char *export_name)
{
assert(in_use > 0);
assert(io_thread_inside());
return nfs_glue->GetConnection(server, export_name);
}

View File

@@ -23,10 +23,11 @@
#include "check.h"
#include "Compiler.h"
class EventLoop;
class NfsConnection;
void
nfs_init();
nfs_init(EventLoop &event_loop);
void
nfs_finish();

View File

@@ -97,6 +97,8 @@ public:
*/
~NfsManager();
using IdleMonitor::GetEventLoop;
gcc_pure
NfsConnection &GetConnection(const char *server,
const char *export_name);