Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
NLua
Commits
8a34d2f4
"...content/tools/Touch.Server.exe" did not exist on "92c5a9fae79fdbc8957b737ee583e0b2a22d9e00"
Unverified
Commit
8a34d2f4
authored
Jul 26, 2019
by
Vinicius Jarina
Committed by
GitHub
Jul 26, 2019
Browse files
Use `ConcurrentQueue` due a race condition. (#311)
parent
be037f73
Changes
2
Show whitespace changes
Inline
Side-by-side
src/ObjectTranslator.cs
View file @
8a34d2f4
...
...
@@ -2,6 +2,7 @@
using
System.IO
;
using
System.Reflection
;
using
System.Collections.Generic
;
using
System.Collections.Concurrent
;
using
System.Runtime.InteropServices
;
using
KeraLua
;
...
...
@@ -50,7 +51,7 @@ namespace NLua
// object # to object (FIXME - it should be possible to get object address as an object #)
readonly
Dictionary
<
int
,
object
>
_objects
=
new
Dictionary
<
int
,
object
>();
readonly
Queue
<
int
>
finalizedReferences
=
new
Queue
<
int
>();
readonly
Concurrent
Queue
<
int
>
finalizedReferences
=
new
Concurrent
Queue
<
int
>();
internal
EventHandlerContainer
PendingEvents
=
new
EventHandlerContainer
();
MetaFunctions
metaFunctions
;
...
...
@@ -1136,11 +1137,10 @@ namespace NLua
if
(
finalizedReferences
.
Count
==
0
)
return
;
while
(
finalizedReferences
.
Count
!=
0
)
{
int
reference
=
finalizedReferences
.
Dequeue
()
;
int
reference
;
while
(
finalizedReferences
.
Try
Dequeue
(
out
reference
)
)
state
.
Unref
(
LuaRegistry
.
Index
,
reference
);
}
}
}
}
tests/src/LuaTests.cs
View file @
8a34d2f4
...
...
@@ -2384,7 +2384,7 @@ namespace NLuaTest
void
PleaseRunFinalizers
()
{
for
(
int
i
=
0
;
i
<
2
0
;
i
++)
for
(
int
i
=
0
;
i
<
4
0
;
i
++)
{
GC
.
Collect
();
GC
.
WaitForPendingFinalizers
();
...
...
@@ -2412,6 +2412,7 @@ namespace NLuaTest
ImplicitlyCreateATable
(
lua
);
lua
.
State
.
GarbageCollector
(
LuaGC
.
Collect
,
0
);
lua
.
State
.
GarbageCollector
(
LuaGC
.
Collect
,
0
);
int
after2
=
lua
.
State
.
GarbageCollector
(
LuaGC
.
Count
,
0
);
...
...
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