Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
b5fcab9b
Commit
b5fcab9b
authored
Aug 07, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
12621777
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
6 deletions
+4
-6
go/zodb/internal/weak/weak.go
go/zodb/internal/weak/weak.go
+1
-1
go/zodb/internal/weak/weak_test.go
go/zodb/internal/weak/weak_test.go
+3
-5
No files found.
go/zodb/internal/weak/weak.go
View file @
b5fcab9b
...
...
@@ -65,7 +65,7 @@ type Ref struct {
// NewRef creates new weak reference pointing to obj.
//
//
XXX
+ onrelease callback?
//
TODO
+ onrelease callback?
func
NewRef
(
obj
interface
{})
*
Ref
{
// since starting from ~ Go1.4 the GC is precise, we can save interface
// pointers to uintptr and that won't prevent GC from garbage
...
...
go/zodb/internal/weak/weak_test.go
View file @
b5fcab9b
...
...
@@ -53,9 +53,8 @@ func TestIface(t *testing.T) {
}
}
func
TestWeakRef
(
t
*
testing
.
T
)
{
type
T
struct
{
_
[
8
]
int64
}
// large enough not to go into tinyalloc
type
T
struct
{
_
[
8
]
int64
}
// large enough not to go into tinyalloc
p
:=
new
(
T
)
w
:=
NewRef
(
p
)
...
...
@@ -68,16 +67,15 @@ func TestWeakRef(t *testing.T) {
}
}
// perform GC + give finalizers a chance
t
to run.
// perform GC + give finalizers a chance to run.
GC
:=
func
()
{
runtime
.
GC
()
// GC only queues finalizers, not runs them directly. Give it
// some time so that finalizers could have been run.
time
.
Sleep
(
10
*
time
.
Millisecond
)
// XXX hack
time
.
Sleep
(
10
*
time
.
Millisecond
)
// XXX hack
}
assertEq
(
w
.
state
,
objLive
)
assertEq
(
w
.
Get
(),
p
)
assertEq
(
w
.
state
,
objGot
)
...
...
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