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
a9698525
"packages/KeraLua.1.0.19/vscode:/vscode.git/clone" did not exist on "008c44e2f4e1fcf06a864e3f300d7af0e6c81259"
Commit
a9698525
authored
Apr 23, 2016
by
Kalin Toshev
Browse files
Need to protect the translator pool with (global) lock during add/remove
parent
9e671dcc
Changes
1
Show whitespace changes
Inline
Side-by-side
Core/NLua/Lua.cs
View file @
a9698525
...
@@ -99,6 +99,11 @@ namespace NLua
...
@@ -99,6 +99,11 @@ namespace NLua
private
LuaNativeFunction
panicCallback
;
private
LuaNativeFunction
panicCallback
;
private
ObjectTranslator
translator
;
private
ObjectTranslator
translator
;
/// <summary>
/// Used to protect the (global) object translator pool during add/remove
/// </summary>
private
static
readonly
object
translatorPoolLock
=
new
object
();
/// <summary>
/// <summary>
/// Used to ensure multiple .net threads all get serialized by this single lock for access to the lua stack/objects
/// Used to ensure multiple .net threads all get serialized by this single lock for access to the lua stack/objects
/// </summary>
/// </summary>
...
@@ -318,7 +323,10 @@ end
...
@@ -318,7 +323,10 @@ end
LuaLib
.
LuaSetTable
(
luaState
,
-
3
);
LuaLib
.
LuaSetTable
(
luaState
,
-
3
);
LuaLib
.
LuaNetPopGlobalTable
(
luaState
);
LuaLib
.
LuaNetPopGlobalTable
(
luaState
);
translator
=
new
ObjectTranslator
(
this
,
luaState
);
translator
=
new
ObjectTranslator
(
this
,
luaState
);
lock
(
translatorPoolLock
)
{
ObjectTranslatorPool
.
Instance
.
Add
(
luaState
,
translator
);
ObjectTranslatorPool
.
Instance
.
Add
(
luaState
,
translator
);
}
LuaLib
.
LuaNetPopGlobalTable
(
luaState
);
LuaLib
.
LuaNetPopGlobalTable
(
luaState
);
LuaLib
.
LuaLDoString
(
luaState
,
Lua
.
initLuanet
);
LuaLib
.
LuaLDoString
(
luaState
,
Lua
.
initLuanet
);
}
}
...
@@ -329,8 +337,11 @@ end
...
@@ -329,8 +337,11 @@ end
return
;
return
;
if
(!
CheckNull
.
IsNull
(
luaState
))
{
if
(!
CheckNull
.
IsNull
(
luaState
))
{
ObjectTranslatorPool
.
Instance
.
Remove
(
luaState
);
lock
(
translatorPoolLock
)
{
LuaCore
.
LuaClose
(
luaState
);
LuaCore
.
LuaClose
(
luaState
);
ObjectTranslatorPool
.
Instance
.
Remove
(
luaState
);
}
}
}
}
}
...
...
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