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) (
// TODO set it to Connection.CacheControl
type zodbCacheControl struct {}
func (cc *zodbCacheControl) WantEvict(obj Object) bool {
func (cc *zodbCacheControl) WantEvict(obj IPersistent) bool {
switch obj.(type) {
default:
return true
......
......@@ -22,11 +22,8 @@ import (
"lab.nexedi.com/kirr/neo/go/zodb"
)
// Object is the interface that every in-RAM object representing any ZODB object implements.
//
// It is analog to Persistent in ZODB.
// XXX rename -> Persistent?
type Object interface {
// IPersistent is the interface that every in-RAM object representing any ZODB object implements.
type IPersistent interface {
PJar() *Connection // Connection this in-RAM object is part of.
POid() zodb.Oid // object ID in the database.
......@@ -85,7 +82,7 @@ type Object interface {
// Object must be stateful for persistency to work
// XXX try to move out of Object?
// XXX try to move out of IPersistent?
Stateful
}
......@@ -108,7 +105,7 @@ type object struct {
mu sync.Mutex
state ObjectState
refcnt int32
instance Object // object should be the base for the instance
instance IPersistent // object should be the base for the instance
loading *loadState
}
......@@ -151,7 +148,7 @@ type Stateful interface {
//
// 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.
//
// XXX ^^^ better must be safe - use case: e.g. prefetch.
......@@ -207,7 +204,7 @@ type Connection struct {
// 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
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.
cacheControl LiveCacheControl
......@@ -223,13 +220,13 @@ type LiveCacheControl interface {
//
// NOTE on invalidation invalidated objects are evicted from live cache
// unconditionally.
WantEvict(obj Object) (ok bool)
WantEvict(obj IPersistent) (ok bool)
}
// ---- activate/deactivate/invalidate ----
// PActivate implements Object.
// PActivate implements IPersistent.
func (obj *object) PActivate(ctx context.Context) (err error) {
obj.mu.Lock()
obj.refcnt++
......@@ -286,7 +283,7 @@ func (obj *object) PActivate(ctx context.Context) (err error) {
return err // XXX err ctx
}
// PDeactivate implements Object.
// PDeactivate implements IPersistent.
func (obj *object) PDeactivate() {
obj.mu.Lock()
defer obj.mu.Unlock()
......@@ -316,7 +313,7 @@ func (obj *object) PDeactivate() {
obj.loading = nil
}
// PInvalidate() implements Object.
// PInvalidate() implements IPersistent.
func (obj *object) PInvalidate() {
obj.mu.Lock()
defer obj.mu.Unlock()
......
......@@ -28,7 +28,7 @@ import (
//
// XXX rename -> PyPersistent?
type PyObject interface {
Object
IPersistent
PyClass() pickle.Class // python class of this object
// PyState() interface{} // object state. python passes this to pyclass.__new__().__setstate__()
......@@ -66,7 +66,7 @@ type PyStateful interface {
// pyinstance returns .instance upcasted to PyObject.
//
// 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 {
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