fixes of review comments

This commit is contained in:
mihacooper 2017-01-20 14:16:29 +03:00
parent f8da71f2f1
commit 5f59d008be
4 changed files with 9 additions and 18 deletions

View File

@ -1,9 +1,4 @@
extern "C"
{
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
}
#include "lua.hpp"
#include "threading.h"
#include "shared-table.h"

View File

@ -69,4 +69,4 @@ TablePool& defaultPool() noexcept {
return pool;
}
} // core
} // share_data

View File

@ -18,19 +18,14 @@ LuaThread::LuaThread(const sol::function& function, const sol::variadic_args& ar
share_data::SharedTable::get_user_type(*p_state_);
// 3. Save parameters
validate_args(args);
store_args(args);
// 4. Run thread
p_thread_.reset(new std::thread(&LuaThread::work, this));
assert(p_thread_.get() != NULL);
}
LuaThread::~LuaThread()
{
join();
}
void LuaThread::validate_args(const sol::variadic_args& args) noexcept
void LuaThread::store_args(const sol::variadic_args& args) noexcept
{
const auto end = --args.end();
for(auto iter = args.begin(); iter != end; iter++)

View File

@ -1,19 +1,20 @@
#pragma once
#include "shared-table.h"
#include <sol.hpp>
#include <iostream>
#include <sstream>
#include <thread>
#include "shared-table.h"
namespace threading {
class LuaThread
{
public:
LuaThread(const sol::function& function, const sol::variadic_args& args) noexcept;
virtual ~LuaThread() noexcept;
virtual ~LuaThread() noexcept = default;
void join() noexcept;
static std::string thread_id() noexcept;
@ -21,7 +22,7 @@ public:
private:
void work() noexcept;
void validate_args(const sol::variadic_args& args) noexcept;
void store_args(const sol::variadic_args& args) noexcept;
std::string str_function_;
std::shared_ptr<sol::state> p_state_;