Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
fa2905f1
Commit
fa2905f1
authored
Aug 08, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
8232e3b8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
go/zodb/persistent.go
go/zodb/persistent.go
+13
-9
No files found.
go/zodb/persistent.go
View file @
fa2905f1
...
...
@@ -62,7 +62,7 @@ type Persistent struct {
jar
*
Connection
oid
Oid
serial
Tid
serial
Tid
// also protected by mu
mu
sync
.
Mutex
state
ObjectState
...
...
@@ -76,7 +76,12 @@ type Persistent struct {
func
(
obj
*
Persistent
)
PJar
()
*
Connection
{
return
obj
.
jar
}
func
(
obj
*
Persistent
)
POid
()
Oid
{
return
obj
.
oid
}
func
(
obj
*
Persistent
)
PSerial
()
Tid
{
return
obj
.
serial
}
func
(
obj
*
Persistent
)
PSerial
()
Tid
{
obj
.
mu
.
Lock
()
defer
obj
.
mu
.
Unlock
()
return
obj
.
serial
}
// loadState indicates object's load state/result.
//
...
...
@@ -123,6 +128,7 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
defer
func
()
{
if
err
!=
nil
{
obj
.
PDeactivate
()
xerr
.
Contextf
(
&
err
,
"%s(%s): activate"
,
obj
.
zclass
.
class
,
obj
.
oid
)
}
}()
//fmt.Printf("activate %p(%v)\t%T(%s): refcnt=%d state=%v\n",
...
...
@@ -135,9 +141,9 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
select
{
case
<-
ctx
.
Done
()
:
return
ctx
.
Err
()
// XXX err ctx
return
ctx
.
Err
()
case
<-
loading
.
ready
:
return
loading
.
err
// XXX err ctx?
return
loading
.
err
}
}
...
...
@@ -148,7 +154,6 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
// do the loading outside of obj lock
state
,
serial
,
err
:=
obj
.
jar
.
load
(
ctx
,
obj
.
oid
)
xerr
.
Contextf
(
&
err
,
"%s(%s): load"
,
obj
.
zclass
.
class
,
obj
.
oid
)
// relock the object
obj
.
mu
.
Lock
()
...
...
@@ -163,12 +168,11 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
switch
istate
:=
obj
.
istate
()
.
(
type
)
{
case
Stateful
:
err
=
istate
.
SetState
(
state
)
xerr
.
Context
f
(
&
err
,
"%s(%s): setstate"
,
obj
.
zclass
.
class
,
obj
.
oid
)
xerr
.
Context
(
&
err
,
"setstate"
)
case
PyStateful
:
err
=
pySetState
(
istate
,
obj
.
zclass
.
class
,
state
,
obj
.
jar
)
xerr
.
Contextf
(
&
err
,
"%s(%s): pysetstate"
,
obj
.
zclass
.
class
,
obj
.
oid
)
xerr
.
Context
(
&
err
,
"pysetstate"
)
default
:
panic
(
"!stateful instance"
)
...
...
@@ -185,7 +189,7 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
obj
.
mu
.
Unlock
()
close
(
loading
.
ready
)
return
err
// XXX err ctx
return
err
}
// PDeactivate implements IPersistent.
...
...
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