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
cb07d772
Commit
cb07d772
authored
Aug 23, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
40256267
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
go/neo/client/cache.go
go/neo/client/cache.go
+16
-14
No files found.
go/neo/client/cache.go
View file @
cb07d772
...
...
@@ -88,16 +88,6 @@ type revCacheEntry struct {
ready
chan
struct
{}
// closed when loading finished
}
// loaded reports whether rce was already loaded
func
(
rce
*
revCacheEntry
)
loaded
()
bool
{
select
{
case
<-
rce
.
ready
:
return
true
default
:
return
false
}
}
// XXX doc
func
(
oce
*
oidCacheEntry
)
newRevEntry
(
before
zodb
.
Tid
)
*
revCacheEntry
{
rce
:=
&
revCacheEntry
{
...
...
@@ -135,12 +125,13 @@ func (oce *oidCacheEntry) del(rce *revCacheEntry) {
rce
.
revv
=
append
(
rce
.
revv
[
:
i
],
rce
.
revv
[
i
+
1
:
])
}
// lock order: Cache > cacheEntry > (?) revCacheEntry
// lock order: Cache.mu > oidCacheEntry > (?) revCacheEntry
// Cache.gcMu > ?
// XXX maintain nhit / nmiss?
func
(
c
*
cache
)
Load
(
xid
zodb
.
Xid
)
(
data
[]
byte
,
tid
Tid
,
err
error
)
{
// oid -> oce (oidCacheEntry) ; creat
ing new empty
if not yet there
// oid -> oce (oidCacheEntry) ; creat
e new empty oce
if not yet there
// exit with oce locked and cache.before read consistently
c
.
mu
.
RLock
()
...
...
@@ -152,6 +143,7 @@ func (c *cache) Load(xid zodb.Xid) (data []byte, tid Tid, err error) {
oce
.
Lock
()
c
.
mu
.
RUnlock
()
}
else
{
// relock cache in write mode to create oce
c
.
mu
.
RUnlock
()
c
.
mu
.
Lock
()
oce
=
c
.
entryMap
[
xid
.
Oid
]
...
...
@@ -166,7 +158,7 @@ func (c *cache) Load(xid zodb.Xid) (data []byte, tid Tid, err error) {
// oce, before -> rce (revCacheEntry)
var
rce
*
revCacheEntry
var
rceNew
bool
// whether
rce created
anew
var
rceNew
bool
// whether
we created rce
anew
if
xid
.
TidBefore
{
l
:=
len
(
oce
.
revv
)
...
...
@@ -252,7 +244,8 @@ func (c *cache) Load(xid zodb.Xid) (data []byte, tid Tid, err error) {
oce
.
Lock
()
i
:=
oce
.
find
(
rce
)
if
i
==
-
1
{
// rce was already dropped / evicted
// rce was already dropped by merge / evicted
// (XXX recheck about evicted)
oce
.
Unlock
()
return
rce
.
data
,
rce
.
serial
,
rce
.
err
}
...
...
@@ -337,6 +330,15 @@ func (c *cache) cleaner() {
}
// loaded reports whether rce was already loaded
func
(
rce
*
revCacheEntry
)
loaded
()
bool
{
select
{
case
<-
rce
.
ready
:
return
true
default
:
return
false
}
}
// revCacheEntry: .inLRU -> .
func
(
h
*
listHead
)
rceFromInLRU
()
(
rce
*
revCacheEntry
)
{
...
...
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