Commit 785acadf authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 873b5e4b
...@@ -105,7 +105,7 @@ type object struct { ...@@ -105,7 +105,7 @@ type object struct {
mu sync.Mutex mu sync.Mutex
state ObjectState state ObjectState
refcnt int32 refcnt int32
instance Object instance Object // object should be the base for the instance
loading *loadState loading *loadState
} }
...@@ -138,7 +138,7 @@ type Stateful interface { ...@@ -138,7 +138,7 @@ type Stateful interface {
SetState(state *mem.Buf) error SetState(state *mem.Buf) error
// GetState should return state of the in-RAM object as raw data. // GetState should return state of the in-RAM object as raw data.
//GetState() *mem.Buf //GetState() *mem.Buf TODO
} }
...@@ -206,7 +206,6 @@ type Connection struct { ...@@ -206,7 +206,6 @@ type Connection struct {
objmu sync.Mutex objmu sync.Mutex
objtab map[zodb.Oid]*WeakRef // oid -> WeakRef(Object) objtab map[zodb.Oid]*WeakRef // oid -> WeakRef(Object)
// hooks for application to influence live caching decisions. // hooks for application to influence live caching decisions.
cacheControl LiveCacheControl cacheControl LiveCacheControl
} }
...@@ -267,12 +266,13 @@ func (obj *object) PActivate(ctx context.Context) (err error) { ...@@ -267,12 +266,13 @@ func (obj *object) PActivate(ctx context.Context) (err error) {
obj.serial = serial obj.serial = serial
// try to pass loaded state to object
if err == nil { if err == nil {
err = obj.instance.SetState(state) // XXX err ctx err = obj.instance.SetState(state) // XXX err ctx
state.Release() state.Release()
} if err == nil {
if err == nil { obj.state = UPTODATE
obj.state = UPTODATE }
} }
loading.err = err loading.err = err
......
...@@ -31,7 +31,7 @@ type PyObject interface { ...@@ -31,7 +31,7 @@ type PyObject interface {
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__()
// PyObject must be statefule for persistency to work // PyObject must be stateful for persistency to work
// XXX try to move out of PyObject? Rationale: we do not want e.g. PySetState to // XXX try to move out of PyObject? Rationale: we do not want e.g. PySetState to
// be available to user who holds PyObject interface: it is confusing to have // be available to user who holds PyObject interface: it is confusing to have
// both PActivate and PySetState at the same time. // both PActivate and PySetState at the same time.
...@@ -50,15 +50,13 @@ func (pyobj *pyObject) PyClass() pickle.Class { return pyobj.pyclass } ...@@ -50,15 +50,13 @@ func (pyobj *pyObject) PyClass() pickle.Class { return pyobj.pyclass }
// PyStateful is the interface describing in-RAM object whose data state can be // PyStateful is the interface describing in-RAM object whose data state can be
// exchanged as Python data. // exchanged as Python data.
type PyStateful interface { type PyStateful interface {
//Stateful XXX no need here?
// PySetState should set state of the in-RAM object from Python data. // PySetState should set state of the in-RAM object from Python data.
// Analog of __setstate__() in Python. // Analog of __setstate__() in Python.
PySetState(pystate interface{}) error PySetState(pystate interface{}) error
// PyGetState should return state of the in-RAM object as Python data. // PyGetState should return state of the in-RAM object as Python data.
// Analog of __getstate__() in Python. // Analog of __getstate__() in Python.
//PyGetState() interface{} XXX //PyGetState() interface{} TODO
} }
// ---- pyObject <-> object state exchange ---- // ---- pyObject <-> object state exchange ----
...@@ -78,7 +76,7 @@ func (pyobj *pyObject) SetState(state *mem.Buf) error { ...@@ -78,7 +76,7 @@ func (pyobj *pyObject) SetState(state *mem.Buf) error {
} }
if pyclass != pyobj.pyclass { if pyclass != pyobj.pyclass {
// complain pyclass changed // complain that pyclass changed
// (both ref and object data use pyclass so it indeed can be different) // (both ref and object data use pyclass so it indeed can be different)
return &wrongClassError{want: pyobj.pyclass, have: pyclass} // XXX + err ctx return &wrongClassError{want: pyobj.pyclass, have: pyclass} // XXX + err ctx
} }
...@@ -90,6 +88,7 @@ func (pyobj *pyObject) SetState(state *mem.Buf) error { ...@@ -90,6 +88,7 @@ func (pyobj *pyObject) SetState(state *mem.Buf) error {
// ---- pyclass -> new ghost ---- // ---- pyclass -> new ghost ----
// function representing new of a class.
type pyClassNewFunc func(base *pyObject) PyObject type pyClassNewFunc func(base *pyObject) PyObject
// path(pyclass) -> new(pyobj) // path(pyclass) -> new(pyobj)
......
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