Commit 3a755a42 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c11843b4
......@@ -91,6 +91,14 @@ cdef extern from "wcfs.h" nogil:
pair[WatchLink, error] _openwatch() # XXX pair instead of tuple
cppclass _Conn:
# XXX
pass
cppclass Conn (refptr[_Conn]):
# XXX
pass
cdef class PyWCFS:
cdef WCFS wc
......
......@@ -22,6 +22,13 @@
#ifndef _NXD_WCFS_H_
#define _NXD_WCFS_H_
#include <golang/libgolang.h>
#include <golang/cxx.h>
#include <golang/sync.h>
using namespace golang;
using cxx::dict;
using cxx::set;
#include <string>
using std::string;
......@@ -33,8 +40,10 @@ using std::pair;
#include "wcfs_misc.h"
struct _Conn;
class _WatchLink;
struct _File;
struct PinReq;
typedef refptr<class _Conn> Conn;
typedef refptr<class _WatchLink> WatchLink;
// WCFS represents filesystem-level connection to wcfs server.
......@@ -42,10 +51,51 @@ class _WatchLink;
struct WCFS {
string mountpoint;
tuple<refptr<_Conn>, error> connect(zodb::Tid at);
string _path(const string &obj);
tuple<os::File, error> _open(const string &path, int flags=O_RDONLY);
pair<refptr<_WatchLink>, error> _openwatch();
tuple<Conn, error> connect(zodb::Tid at);
string _path(const string &obj);
tuple<os::File, error> _open(const string &path, int flags=O_RDONLY);
pair<WatchLink, error> _openwatch();
};
// Conn represents logical connection that provides view of data on wcfs
// filesystem as of particular database state.
//
// It uses /head/bigfile/* and notifications received from /head/watch to
// maintain isolated database view while at the same time sharing most of data
// cache in OS pagecache of /head/bigfile/*.
//
// Use WCFS.connect(at) to create Conn.
// Use .mmap to create new Mappings.
// Use .resync to resync Conn onto different database view.
//
// Conn logically mirrors ZODB.Connection .
typedef refptr<struct _Conn> Conn;
struct _Conn : object {
WCFS *_wc;
zodb::Tid at;
WatchLink _wlink; // watch/receive pins for created mappings
sync::Mutex _filemu;
dict<zodb::Oid, _File*> _filetab; // {} foid -> _file
sync::WorkGroup _pinWG;
func<void()> _pinCancel;
// don't new - create via WCFS.connect
private:
_Conn();
~_Conn();
friend tuple<Conn, error> WCFS::connect(zodb::Tid at);
public:
void decref();
public:
error close();
error resync(zodb::Tid at);
private:
error _pinner(context::Context ctx);
void _pin1(PinReq *req);
};
......
......@@ -50,50 +50,7 @@ static string h(uint64_t v); // v -> 016x hex representation
static error mmap_zero_into_ro(void *addr, size_t size);
static error mmap_into_ro(void *addr, size_t size, const os::File &f, off_t offset);
struct _File;
struct _Mapping;
struct PinReq;
// Conn represents logical connection that provides view of data on wcfs
// filesystem as of particular database state.
//
// It uses /head/bigfile/* and notifications received from /head/watch to
// maintain isolated database view while at the same time sharing most of data
// cache in OS pagecache of /head/bigfile/*.
//
// Use WCFS.connect(at) to create Conn.
// Use .mmap to create new Mappings.
// Use .resync to resync Conn onto different database view.
//
// Conn logically mirrors ZODB.Connection .
typedef refptr<struct _Conn> Conn;
struct _Conn : object {
WCFS *_wc;
zodb::Tid at;
WatchLink _wlink; // watch/receive pins for created mappings
sync::Mutex _filemu;
dict<zodb::Oid, _File*> _filetab; // {} foid -> _file
sync::WorkGroup _pinWG;
func<void()> _pinCancel;
// don't new - create via WCFS.connect
private:
_Conn();
~_Conn();
friend tuple<Conn, error> WCFS::connect(zodb::Tid at);
public:
void decref();
public:
error close();
error resync(zodb::Tid at);
private:
error _pinner(context::Context ctx);
void _pin1(PinReq *req);
};
// _File represent isolated file view under Conn.
//
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment