diff --git a/examples/lua_plugin/CMakeLists.txt b/examples/lua_plugin/CMakeLists.txt index 4d6708b..09c45f4 100644 --- a/examples/lua_plugin/CMakeLists.txt +++ b/examples/lua_plugin/CMakeLists.txt @@ -5,4 +5,6 @@ add_custom_command( TARGET lua_plugin_manager POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/plugin.lua - $) + $/plugin_1.lua + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/plugin.lua + $/plugin_2.lua) diff --git a/examples/lua_plugin/lua_plugin_manager.cpp b/examples/lua_plugin/lua_plugin_manager.cpp index 8cc8f9d..88a95b0 100644 --- a/examples/lua_plugin/lua_plugin_manager.cpp +++ b/examples/lua_plugin/lua_plugin_manager.cpp @@ -36,9 +36,11 @@ int main(int argc, char* argv[]) // only load files ending with ".lua" and execute in separate thread if (path.extension() == ".lua") { if (auto plugin = manager.loadLuaPlugin(path)) { - threads.emplace_back([plugin = std::move(*plugin)]() mutable { + threads.emplace_back([plugin = std::move(*plugin), plugin_number = threads.size()]() mutable { + // data race due to shared resource "stdout", + // but Lua plugins are otherwise thread-safe std::ignore = plugin.call("initialize"); - std::ignore = plugin.call("loop", "2"); + std::ignore = plugin.call("loop", plugin_number); }); } }