Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-eventbus
Commits
d88ec38b
Unverified
Commit
d88ec38b
authored
Jun 28, 2019
by
Łukasz Magiera
Committed by
GitHub
Jun 28, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19 from libp2p/fix/16
fix: serialize publishing
parents
04058af2
25d54bbb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
basic.go
basic.go
+6
-6
No files found.
basic.go
View file @
d88ec38b
...
...
@@ -173,7 +173,7 @@ func (b *basicBus) Subscribe(evtTypes interface{}, opts ...event.SubscriptionOpt
out
.
nodes
[
i
]
=
n
},
func
(
n
*
node
)
{
if
n
.
keepLast
{
l
:=
n
.
last
.
Load
()
l
:=
n
.
last
if
l
==
nil
{
return
}
...
...
@@ -223,7 +223,7 @@ func (b *basicBus) Emitter(evtType interface{}, opts ...event.EmitterOpt) (e eve
type
node
struct
{
// Note: make sure to NEVER lock basicBus.lk when this lock is held
lk
sync
.
RW
Mutex
lk
sync
.
Mutex
typ
reflect
.
Type
...
...
@@ -231,7 +231,7 @@ type node struct {
nEmitters
int32
keepLast
bool
last
atomic
.
Value
last
interface
{}
sinks
[]
chan
interface
{}
}
...
...
@@ -248,13 +248,13 @@ func (n *node) emit(event interface{}) {
panic
(
fmt
.
Sprintf
(
"Emit called with wrong type. expected: %s, got: %s"
,
n
.
typ
,
typ
))
}
n
.
lk
.
R
Lock
()
n
.
lk
.
Lock
()
if
n
.
keepLast
{
n
.
last
.
Store
(
event
)
n
.
last
=
event
}
for
_
,
ch
:=
range
n
.
sinks
{
ch
<-
event
}
n
.
lk
.
R
Unlock
()
n
.
lk
.
Unlock
()
}
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