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 {
...
@@ -92,24 +92,24 @@ func (d *MutexDatastore) Close() error {
}
}
type
syncBatch
struct
{
type
syncBatch
struct
{
lk
sync
.
Mutex
batch
ds
.
Batch
batch
ds
.
Batch
mds
*
MutexDatastore
}
}
func
(
b
*
syncBatch
)
Put
(
key
ds
.
Key
,
val
interface
{})
error
{
func
(
b
*
syncBatch
)
Put
(
key
ds
.
Key
,
val
interface
{})
error
{
b
.
lk
.
Lock
()
b
.
mds
.
Lock
()
defer
b
.
lk
.
Unlock
()
defer
b
.
mds
.
Unlock
()
return
b
.
batch
.
Put
(
key
,
val
)
return
b
.
batch
.
Put
(
key
,
val
)
}
}
func
(
b
*
syncBatch
)
Delete
(
key
ds
.
Key
)
error
{
func
(
b
*
syncBatch
)
Delete
(
key
ds
.
Key
)
error
{
b
.
lk
.
Lock
()
b
.
mds
.
Lock
()
defer
b
.
lk
.
Unlock
()
defer
b
.
mds
.
Unlock
()
return
b
.
batch
.
Delete
(
key
)
return
b
.
batch
.
Delete
(
key
)
}
}
func
(
b
*
syncBatch
)
Commit
()
error
{
func
(
b
*
syncBatch
)
Commit
()
error
{
b
.
lk
.
Lock
()
b
.
mds
.
Lock
()
defer
b
.
lk
.
Unlock
()
defer
b
.
mds
.
Unlock
()
return
b
.
batch
.
Commit
()
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