Commit 7a8cebf5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent ae2044cd
...@@ -478,7 +478,7 @@ func (bf *BigFile) Read(_ nodefs.File, dest []byte, off int64, _ fuse.Context) ( ...@@ -478,7 +478,7 @@ func (bf *BigFile) Read(_ nodefs.File, dest []byte, off int64, _ fuse.Context) (
// TODO set it to Connection.CacheControl // TODO set it to Connection.CacheControl
type zodbCacheControl struct {} type zodbCacheControl struct {}
func (cc *zodbCacheControl) WantEvict(obj Object) bool { func (cc *zodbCacheControl) WantEvict(obj IPersistent) bool {
switch obj.(type) { switch obj.(type) {
default: default:
return true return true
......
...@@ -22,11 +22,8 @@ import ( ...@@ -22,11 +22,8 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb" "lab.nexedi.com/kirr/neo/go/zodb"
) )
// Object is the interface that every in-RAM object representing any ZODB object implements. // IPersistent is the interface that every in-RAM object representing any ZODB object implements.
// type IPersistent interface {
// It is analog to Persistent in ZODB.
// XXX rename -> Persistent?
type Object interface {
PJar() *Connection // Connection this in-RAM object is part of. PJar() *Connection // Connection this in-RAM object is part of.
POid() zodb.Oid // object ID in the database. POid() zodb.Oid // object ID in the database.
...@@ -85,7 +82,7 @@ type Object interface { ...@@ -85,7 +82,7 @@ type Object interface {
// Object must be stateful for persistency to work // Object must be stateful for persistency to work
// XXX try to move out of Object? // XXX try to move out of IPersistent?
Stateful Stateful
} }
...@@ -108,7 +105,7 @@ type object struct { ...@@ -108,7 +105,7 @@ type object struct {
mu sync.Mutex mu sync.Mutex
state ObjectState state ObjectState
refcnt int32 refcnt int32
instance Object // object should be the base for the instance instance IPersistent // object should be the base for the instance
loading *loadState loading *loadState
} }
...@@ -151,7 +148,7 @@ type Stateful interface { ...@@ -151,7 +148,7 @@ type Stateful interface {
// //
// Connection changes are private and are isolated from changes in other Connections. // Connection changes are private and are isolated from changes in other Connections.
// //
// XXX Connection, and {Py}Object methods that relate to it, are not safe for // XXX Connection, and I{Py}Persistent methods that relate to it, are not safe for
// modifications from multiple goroutines simultaneously. // modifications from multiple goroutines simultaneously.
// //
// XXX ^^^ better must be safe - use case: e.g. prefetch. // XXX ^^^ better must be safe - use case: e.g. prefetch.
...@@ -207,7 +204,7 @@ type Connection struct { ...@@ -207,7 +204,7 @@ type Connection struct {
// NOTE2 finalizers don't run on when they are attached to an object in cycle. // NOTE2 finalizers don't run on when they are attached to an object in cycle.
// Hopefully we don't have cycles with ZBtree/ZBucket XXX verify this // Hopefully we don't have cycles with ZBtree/ZBucket XXX verify this
objmu sync.Mutex objmu sync.Mutex
objtab map[zodb.Oid]*WeakRef // oid -> WeakRef(Object) objtab map[zodb.Oid]*WeakRef // oid -> WeakRef(IPersistent)
// hooks for application to influence live caching decisions. // hooks for application to influence live caching decisions.
cacheControl LiveCacheControl cacheControl LiveCacheControl
...@@ -223,13 +220,13 @@ type LiveCacheControl interface { ...@@ -223,13 +220,13 @@ type LiveCacheControl interface {
// //
// NOTE on invalidation invalidated objects are evicted from live cache // NOTE on invalidation invalidated objects are evicted from live cache
// unconditionally. // unconditionally.
WantEvict(obj Object) (ok bool) WantEvict(obj IPersistent) (ok bool)
} }
// ---- activate/deactivate/invalidate ---- // ---- activate/deactivate/invalidate ----
// PActivate implements Object. // PActivate implements IPersistent.
func (obj *object) PActivate(ctx context.Context) (err error) { func (obj *object) PActivate(ctx context.Context) (err error) {
obj.mu.Lock() obj.mu.Lock()
obj.refcnt++ obj.refcnt++
...@@ -286,7 +283,7 @@ func (obj *object) PActivate(ctx context.Context) (err error) { ...@@ -286,7 +283,7 @@ func (obj *object) PActivate(ctx context.Context) (err error) {
return err // XXX err ctx return err // XXX err ctx
} }
// PDeactivate implements Object. // PDeactivate implements IPersistent.
func (obj *object) PDeactivate() { func (obj *object) PDeactivate() {
obj.mu.Lock() obj.mu.Lock()
defer obj.mu.Unlock() defer obj.mu.Unlock()
...@@ -316,7 +313,7 @@ func (obj *object) PDeactivate() { ...@@ -316,7 +313,7 @@ func (obj *object) PDeactivate() {
obj.loading = nil obj.loading = nil
} }
// PInvalidate() implements Object. // PInvalidate() implements IPersistent.
func (obj *object) PInvalidate() { func (obj *object) PInvalidate() {
obj.mu.Lock() obj.mu.Lock()
defer obj.mu.Unlock() defer obj.mu.Unlock()
......
...@@ -28,7 +28,7 @@ import ( ...@@ -28,7 +28,7 @@ import (
// //
// XXX rename -> PyPersistent? // XXX rename -> PyPersistent?
type PyObject interface { type PyObject interface {
Object IPersistent
PyClass() pickle.Class // python class of this object PyClass() pickle.Class // python class of this object
// PyState() interface{} // object state. python passes this to pyclass.__new__().__setstate__() // PyState() interface{} // object state. python passes this to pyclass.__new__().__setstate__()
...@@ -66,7 +66,7 @@ type PyStateful interface { ...@@ -66,7 +66,7 @@ type PyStateful interface {
// pyinstance returns .instance upcasted to PyObject. // pyinstance returns .instance upcasted to PyObject.
// //
// this should be always safe because we always create pyObjects via // this should be always safe because we always create pyObjects via
// newGhost which passes PyObject as instance to Object. // newGhost which passes PyObject as instance to IPersistent.
func (pyobj *pyObject) pyinstance() PyObject { func (pyobj *pyObject) pyinstance() PyObject {
return pyobj.instance.(PyObject) return pyobj.instance.(PyObject)
} }
......
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