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
dms3
go-datastore
Commits
263918b3
Commit
263918b3
authored
Jan 13, 2016
by
Juan Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #35 from whyrusleeping/fix/sync-batch
fix locking in syncbatch
parents
19e39c85
0f07328c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
sync/sync.go
sync/sync.go
+7
-7
No files found.
sync/sync.go
View file @
263918b3
...
...
@@ -92,24 +92,24 @@ func (d *MutexDatastore) Close() error {
}
type
syncBatch
struct
{
lk
sync
.
Mutex
batch
ds
.
Batch
mds
*
MutexDatastore
}
func
(
b
*
syncBatch
)
Put
(
key
ds
.
Key
,
val
interface
{})
error
{
b
.
lk
.
Lock
()
defer
b
.
lk
.
Unlock
()
b
.
mds
.
Lock
()
defer
b
.
mds
.
Unlock
()
return
b
.
batch
.
Put
(
key
,
val
)
}
func
(
b
*
syncBatch
)
Delete
(
key
ds
.
Key
)
error
{
b
.
lk
.
Lock
()
defer
b
.
lk
.
Unlock
()
b
.
mds
.
Lock
()
defer
b
.
mds
.
Unlock
()
return
b
.
batch
.
Delete
(
key
)
}
func
(
b
*
syncBatch
)
Commit
()
error
{
b
.
lk
.
Lock
()
defer
b
.
lk
.
Unlock
()
b
.
mds
.
Lock
()
defer
b
.
mds
.
Unlock
()
return
b
.
batch
.
Commit
()
}
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