Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
0290d904
Commit
0290d904
authored
Jul 19, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
39e27aa5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
76 deletions
+38
-76
wcfs/zodb.go
wcfs/zodb.go
+38
-76
No files found.
wcfs/zodb.go
View file @
0290d904
...
...
@@ -437,71 +437,7 @@ func (d *dummyPyInstance) PySetState(pystate interface{}) error {
}
// ----------------------------------------
// object's activate & friends that only manage base activation state, without actually loading data.
// XXX ^^^ still relevant?
/*
// activate increments object reference counter.
//
// it returns whether object data needs to be loaded.
// the caller must adjust .state after loading is complete.
//
// must be called with .mu held.
func (obj *object) activate() (load bool) {
obj.refcnt++
return (obj.refcnt == 1 && obj.state == GHOST)
}
*/
// deactivate decrements object reference counter.
//
// it returns whether object data needs to be discarded.
// must be called with .mu held.
func
(
obj
*
object
)
deactivate
()
(
drop
bool
)
{
//nuse := atomic.AddInt32(&obj.refcnt, -1)
obj
.
refcnt
--
if
obj
.
refcnt
<
0
{
panic
(
"deactivate: refcnt < 0"
)
}
if
obj
.
refcnt
>
0
{
return
false
// users still left
}
// no users left. Let's see whether we should transition this object to ghost.
if
obj
.
state
>=
CHANGED
{
return
false
}
// XXX -> pyObject?
if
cc
:=
obj
.
jar
.
cacheControl
;
cc
!=
nil
{
if
!
cc
.
WantEvict
(
obj
.
instance
)
{
return
false
}
}
obj
.
serial
=
0
obj
.
instance
.
DropState
()
obj
.
state
=
GHOST
return
true
}
// invalidate XXX
//
// must be called with .mu held.
func
(
obj
*
object
)
invalidate
()
{
if
obj
.
refcnt
!=
0
{
// object is currently in use
panic
(
"invalidate: refcnt != 0"
)
}
obj
.
serial
=
0
obj
.
instance
.
DropState
()
obj
.
state
=
GHOST
}
// ---- activate/deactivate/invalidate ----
// PActivate implements Object.
func
(
obj
*
object
)
PActivate
(
ctx
context
.
Context
)
(
err
error
)
{
...
...
@@ -571,21 +507,47 @@ func (obj *object) PActivate(ctx context.Context) (err error) {
// PDeactivate implements Object.
func
(
pyobj
*
pyObject
)
PDeactivate
()
{
pyobj
.
mu
.
Lock
()
defer
pyobj
.
mu
.
Unlock
()
func
(
obj
*
Object
)
PDeactivate
()
{
obj
.
mu
.
Lock
()
defer
obj
.
mu
.
Unlock
()
obj
.
refcnt
--
if
obj
.
refcnt
<
0
{
panic
(
"deactivate: refcnt < 0"
)
}
if
obj
.
refcnt
>
0
{
return
// users still left
}
drop
:=
pyobj
.
deactivate
()
if
drop
{
pyobj
.
loading
=
nil
// no users left. Let's see whether we should transition this object to ghost.
if
obj
.
state
>=
CHANGED
{
return
}
if
cc
:=
obj
.
jar
.
cacheControl
;
cc
!=
nil
{
if
!
cc
.
WantEvict
(
obj
.
instance
)
{
return
}
}
obj
.
serial
=
0
obj
.
instance
.
DropState
()
obj
.
state
=
GHOST
obj
.
loading
=
nil
}
// PInvalidate() implements Object.
func
(
py
obj
*
pyObject
)
PInvalidate
()
{
py
obj
.
mu
.
Lock
()
defer
py
obj
.
mu
.
Unlock
()
func
(
obj
*
pyObject
)
PInvalidate
()
{
obj
.
mu
.
Lock
()
defer
obj
.
mu
.
Unlock
()
pyobj
.
invalidate
()
pyobj
.
loading
=
nil
if
obj
.
refcnt
!=
0
{
// object is currently in use
panic
(
"invalidate: refcnt != 0"
)
}
obj
.
serial
=
0
obj
.
instance
.
DropState
()
obj
.
state
=
GHOST
obj
.
loading
=
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment