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
ef38617b
Commit
ef38617b
authored
Feb 20, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0a6ac0f4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
10 deletions
+29
-10
go/zodb/open.go
go/zodb/open.go
+26
-9
go/zodb/zodb.go
go/zodb/zodb.go
+3
-1
No files found.
go/zodb/open.go
View file @
ef38617b
...
...
@@ -26,6 +26,7 @@ import (
"log"
"net/url"
"strings"
"sync"
"lab.nexedi.com/kirr/go123/mem"
)
...
...
@@ -147,7 +148,7 @@ type storage struct {
driver
IStorageDriver
l1cache
*
Cache
// can be =nil, if opened with NoCache
down
chan
struct
// ready when no longer operational
down
chan
struct
{}
// ready when no longer operational
downErr
error
// reason for shutdown
// watcher
...
...
@@ -159,7 +160,7 @@ type storage struct {
// when watcher is closed (.down is ready) {Add,Del}Watch operate directly
// on .watchTab and interact with each other directly. In that mode:
watchMu
sync
.
Mutex
// for watchTab and * below
watchCancel
map
[
chan
<-
Event
]
struct
{}
// DelWatch can cancel AddWatch via here
watchCancel
map
[
chan
<-
Event
]
chan
struct
{}
// DelWatch can cancel AddWatch via here
}
// loading goes through cache - this way prefetching can work
...
...
@@ -235,6 +236,15 @@ func (s *storage) watcher() {
serveReq
:=
func
(
req
watchRequest
)
{
switch
req
.
op
{
case
addWatch
:
_
,
already
:=
s
.
watchTab
[
req
.
watchq
]
if
!
already
{
_
,
already
=
addq
[
req
.
watchq
]
}
if
already
{
req
.
ack
<-
InvalidTid
return
}
addq
[
req
.
watchq
]
=
struct
{}{}
case
delWatch
:
...
...
@@ -300,7 +310,7 @@ func (s *storage) watcher() {
// deliver event to all watchers.
// handle add/del watchq in the process.
deliver
:
next
:
for
watchq
:=
range
s
.
watchTab
{
for
{
select
{
...
...
@@ -310,12 +320,12 @@ func (s *storage) watcher() {
// else try sending to current watchq once again.
_
,
present
:=
s
.
watchTab
[
watchq
]
if
!
present
{
continue
deliver
continue
next
}
case
watchq
<-
event
:
// ok
continue
deliver
continue
next
}
}
}
...
...
@@ -330,11 +340,13 @@ func (s *storage) AddWatch(watchq chan<- Event) (at0 Tid) {
// no longer operational: behave if watchq was registered before that
// and then seen down/close events. Interact with DelWatch directly.
case
<-
s
.
down
:
at0
=
s
.
drvHead
s
.
watchMu
.
Lock
()
_
,
already
:=
s
.
watchTab
[
watchq
]
if
already
{
s
.
watchMu
.
Unlock
()
return
// multiple AddWatch
panic
(
"multiple AddWatch with the same channel"
)
}
s
.
watchTab
[
watchq
]
=
struct
{}{}
cancel
:=
make
(
chan
struct
{})
...
...
@@ -353,11 +365,16 @@ func (s *storage) AddWatch(watchq chan<- Event) (at0 Tid) {
}
close
(
watchq
)
}()
return
s
.
drvHead
return
at0
// operational - interact with watcher
case
s
.
watchReq
<-
watchRequest
{
addWatch
,
ack
,
watchq
}
:
return
<-
ack
at0
=
<-
ack
if
at0
==
InvalidTid
{
panic
(
"multiple AddWatch with the same channel"
)
}
return
at0
}
}
...
...
go/zodb/zodb.go
View file @
ef38617b
...
...
@@ -472,7 +472,9 @@ type Watcher interface {
//
// Registered watchq are closed when the database storage is closed.
//
// Multiple AddWatch calls with the same watchq register watchq only once.
// It is safe to add watch to a closed database storage.
//
// AddWatch must be used only once for a particular watchq channel.
AddWatch
(
watchq
chan
<-
Event
)
(
at0
Tid
)
// DelWatch unregisters watchq from being notified of database changes.
...
...
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