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
2dad1860
Commit
2dad1860
authored
Feb 19, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f515f4b0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
16 deletions
+50
-16
go/zodb/open.go
go/zodb/open.go
+50
-16
No files found.
go/zodb/open.go
View file @
2dad1860
...
...
@@ -196,27 +196,56 @@ const (
// watcher dispatches events from driver to subscribers and serves
// {Add,Del}Watch requests.
func
(
s
*
storage
)
watcher
()
{
for
{
select
{
case
req
:=
<-
s
.
watchReq
:
// staging place for AddWatch requests.
//
// during event delivery to registered watchqs, add/del requests are
// also served - not to get stuck and support clients who do DelWatch
// and no longer receive from their watchq. However we cannot register
// added watchq immediately, because it is undefined whether or not
// we'll see it while iterating watchTab. So we queue what was added
// and flush it on the beginning of each cycle.
var
addq
map
[
chan
<-
Event
]
struct
{}
addqFlush
:=
func
()
{
for
watchq
:=
range
addq
{
s
.
watchTab
[
watchq
]
=
struct
{}{}
}
addq
=
make
(
map
[
chan
<-
Event
]
struct
{})
}
handleReq
:=
func
(
req
watchRequest
)
{
switch
req
.
op
{
case
addWatch
:
s
.
watchTab
[
req
.
watchq
]
=
struct
{}{}
addq
[
req
.
watchq
]
=
struct
{}{}
case
delWatch
:
delete
(
s
.
watchTab
,
req
.
watchq
)
delete
(
addq
,
req
.
watchq
)
default
:
panic
(
"bad watch request op"
)
}
req
.
ack
<-
s
.
drvHead
}
// close all subscribers's watchq on close
// XXX AddWatch/DelWatch after watcher exits?
defer
func
()
{
addqFlush
()
for
watchq
:=
range
s
.
watchTab
{
close
(
watchq
)
}
}()
for
{
addqFlush
()
// register staged AddWatch(s)
select
{
case
req
:=
<-
s
.
watchReq
:
handleReq
(
req
)
case
event
,
ok
:=
<-
s
.
drvWatchq
:
if
!
ok
{
// storage closed
// XXX close all subscribers' watchq?
// XXX AddWatch/DelWatch after watcher exits?
return
}
...
...
@@ -235,8 +264,13 @@ func (s *storage) watcher() {
// deliver event to all watchers
for
watchq
:=
range
s
.
watchTab
{
// XXX + select and handle DelWatch
watchq
<-
event
select
{
case
req
:=
<-
s
.
watchReq
:
handleReq
(
req
)
case
watchq
<-
event
:
// ok
}
}
}
}
...
...
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