diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-02-23 15:00:59 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-02-23 15:00:59 +0100 |
commit | e292144d46e3fbb24ee9ee67f1682b268373921b (patch) | |
tree | 318c8baaca0739076dcbcbe0d530f5e8d97fc204 /src/libstore/remote-store.hh | |
parent | c0b7a8a0b576d5fcbcb25c412836dc885b7eb0fe (diff) |
RemoteStore: Make thread-safe
This allows a RemoteStore object to be used safely from multiple
threads concurrently. It will make multiple daemon connections if
necessary.
Note: pool.hh and sync.hh have been copied from the Hydra source tree.
Diffstat (limited to 'src/libstore/remote-store.hh')
-rw-r--r-- | src/libstore/remote-store.hh | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh index f15182285..b16a6b51d 100644 --- a/src/libstore/remote-store.hh +++ b/src/libstore/remote-store.hh @@ -12,6 +12,7 @@ class Pipe; class Pid; struct FdSink; struct FdSource; +template<typename T> class Pool; class RemoteStore : public Store @@ -91,19 +92,22 @@ public: bool verifyStore(bool checkContents, bool repair) override; private: - AutoCloseFD fdSocket; - FdSink to; - FdSource from; - unsigned int daemonVersion; - bool initialised; - void openConnection(bool reserveSpace = true); + struct Connection + { + AutoCloseFD fd; + FdSink to; + FdSource from; + unsigned int daemonVersion; - void processStderr(Sink * sink = 0, Source * source = 0); + void processStderr(Sink * sink = 0, Source * source = 0); + }; - void connectToDaemon(); + ref<Pool<Connection>> connections; - void setOptions(); + ref<Connection> openConnection(bool reserveSpace = true); + + void setOptions(ref<Connection> conn); }; |