rename project to Effil

This commit is contained in:
mihacooper 2017-01-22 19:30:40 +03:00
parent 797df10e29
commit daefaf979b
12 changed files with 39 additions and 39 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
project(woofer) project(effil)
find_package(Lua REQUIRED) find_package(Lua REQUIRED)
@ -18,13 +18,13 @@ if(APPLE)
set(CMAKE_MACOSX_RPATH 1) set(CMAKE_MACOSX_RPATH 1)
endif() endif()
add_library(woofer SHARED ${SOURCES}) add_library(effil SHARED ${SOURCES})
target_link_libraries(woofer -lpthread ${LUA_LIBRARY}) target_link_libraries(effil -lpthread ${LUA_LIBRARY})
set(GENERAL "-std=c++14 -pthread") set(GENERAL "-std=c++14 -pthread")
set(ENABLE_WARNINGS "-Wall -Wextra -pedantic -Werror") set(ENABLE_WARNINGS "-Wall -Wextra -pedantic -Werror")
set(BUILD_FLAVOR "-O3 -UNDEBUG") set(BUILD_FLAVOR "-O3 -UNDEBUG")
set_target_properties(woofer PROPERTIES COMPILE_FLAGS "${ENABLE_WARNINGS} ${GENERAL} ${BUILD_FLAVOR}") set_target_properties(effil PROPERTIES COMPILE_FLAGS "${ENABLE_WARNINGS} ${GENERAL} ${BUILD_FLAVOR}")
#---------- #----------
# TESTS --- # TESTS ---
@ -35,7 +35,7 @@ set(GTEST_DIR tests/gtest/googletest)
include_directories(${GTEST_DIR}/include ${GTEST_DIR}) include_directories(${GTEST_DIR}/include ${GTEST_DIR})
add_executable(tests ${TEST_SOURCES} ${GTEST_DIR}/src/gtest-all.cc) add_executable(tests ${TEST_SOURCES} ${GTEST_DIR}/src/gtest-all.cc)
target_link_libraries(tests woofer) target_link_libraries(tests effil)
set_target_properties(tests PROPERTIES COMPILE_FLAGS "${ENABLE_WARNINGS} ${GENERAL} ${BUILD_FLAVOR}") set_target_properties(tests PROPERTIES COMPILE_FLAGS "${ENABLE_WARNINGS} ${GENERAL} ${BUILD_FLAVOR}")

View File

@ -1,4 +1,4 @@
# Woofer # Effil
Threading library for Lua. Written in C++ with great help of [sol2](https://github.com/ThePhD/sol2). Threading library for Lua. Written in C++ with great help of [sol2](https://github.com/ThePhD/sol2).
[![Build Status](https://travis-ci.org/loud-hound/woofer.svg?branch=master)](https://travis-ci.org/loud-hound/woofer) [![Build Status](https://travis-ci.org/loud-hound/woofer.svg?branch=master)](https://travis-ci.org/loud-hound/woofer)

View File

@ -1,15 +1,15 @@
TestSmoke = {} TestSmoke = {}
function TestSmoke:testGeneralWorkability() function TestSmoke:testGeneralWorkability()
local woofer = require('libwoofer') local effil = require('libeffil')
local share = woofer.share() local share = effil.share()
share["number"] = 100500 share["number"] = 100500
share["string"] = "string value" share["string"] = "string value"
share["bool"] = true share["bool"] = true
log "Start thread" log "Start thread"
local thread = woofer.thread( local thread = effil.thread(
function(share) function(share)
share["child.number"] = share["number"] share["child.number"] = share["number"]
share["child.string"] = share["string"] share["child.string"] = share["string"]
@ -30,12 +30,12 @@ function TestSmoke:testGeneralWorkability()
end end
function TestSmoke:testDetach() function TestSmoke:testDetach()
local woofer = require('libwoofer') local effil = require('libeffil')
local share = woofer.share() local share = effil.share()
share["finished"] = false share["finished"] = false
log "Start thread" log "Start thread"
local thread = woofer.thread( local thread = effil.thread(
function(share) function(share)
local startTime = os.time() local startTime = os.time()
while ( (os.time() - startTime) <= 3) do --[[ Like we are working 3sec ... ]] end while ( (os.time() - startTime) <= 3) do --[[ Like we are working 3sec ... ]] end

View File

@ -6,19 +6,19 @@
namespace { namespace {
static sol::object createThread(sol::this_state lua, sol::function func, const sol::variadic_args &args) noexcept { static sol::object createThread(sol::this_state lua, sol::function func, const sol::variadic_args &args) noexcept {
return sol::make_object(lua, std::make_unique<threading::LuaThread>(func, args)); return sol::make_object(lua, std::make_unique<effil::LuaThread>(func, args));
} }
static sol::object createShare(sol::this_state lua) noexcept { static sol::object createShare(sol::this_state lua) noexcept {
return sol::make_object(lua, std::make_unique<share_data::SharedTable>()); return sol::make_object(lua, std::make_unique<effil::SharedTable>());
} }
} // namespace } // namespace
extern "C" int luaopen_libwoofer(lua_State *L) { extern "C" int luaopen_libeffil(lua_State *L) {
sol::state_view lua(L); sol::state_view lua(L);
threading::LuaThread::getUserType(lua); effil::LuaThread::getUserType(lua);
share_data::SharedTable::getUserType(lua); effil::SharedTable::getUserType(lua);
sol::table public_api = lua.create_table_with( sol::table public_api = lua.create_table_with(
"thread", createThread, "thread", createThread,
"share", createShare "share", createShare

View File

@ -3,13 +3,13 @@
#include <cassert> #include <cassert>
#include <mutex> #include <mutex>
namespace share_data { namespace effil {
sol::object SharedTable::getUserType(sol::state_view &lua) noexcept { sol::object SharedTable::getUserType(sol::state_view &lua) noexcept {
static sol::usertype<share_data::SharedTable> type( static sol::usertype<SharedTable> type(
sol::call_construction(), sol::default_constructor, sol::call_construction(), sol::default_constructor,
sol::meta_function::new_index, &share_data::SharedTable::luaSet, sol::meta_function::new_index, &SharedTable::luaSet,
sol::meta_function::index, &share_data::SharedTable::luaGet, sol::meta_function::index, &SharedTable::luaGet,
sol::meta_function::length, &SharedTable::size sol::meta_function::length, &SharedTable::size
); );
sol::stack::push(lua, type); sol::stack::push(lua, type);
@ -75,4 +75,4 @@ TablePool& defaultPool() noexcept {
return pool; return pool;
} }
} // share_data } // effil

View File

@ -9,7 +9,7 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
namespace share_data { namespace effil {
class SharedTable { class SharedTable {
public: public:
@ -50,4 +50,4 @@ private:
TablePool& defaultPool() noexcept; TablePool& defaultPool() noexcept;
} // share_data } // effil

View File

@ -3,7 +3,7 @@
#include <atomic> #include <atomic>
#include <thread> #include <thread>
namespace share_data { namespace effil {
class SpinMutex { class SpinMutex {
public: public:
@ -21,4 +21,4 @@ private:
std::atomic_flag lock_ = ATOMIC_FLAG_INIT; std::atomic_flag lock_ = ATOMIC_FLAG_INIT;
}; };
} // share_data } // effil

View File

@ -9,7 +9,7 @@
#include <cassert> #include <cassert>
namespace share_data { namespace effil {
namespace { namespace {
@ -211,4 +211,4 @@ bool StoredObject::operator<(const StoredObject& o) const noexcept {
return data_.get() < o.data_.get(); return data_.get() < o.data_.get();
} }
} // share_data } // effil

View File

@ -5,7 +5,7 @@
#include <utility> #include <utility>
#include <iostream> #include <iostream>
namespace share_data { namespace effil {
class BaseHolder { class BaseHolder {
public: public:
@ -63,14 +63,14 @@ private:
StoredObject& operator=(const StoredObject&) = delete; StoredObject& operator=(const StoredObject&) = delete;
}; };
} // share_data } // effil
namespace std { namespace std {
// For storing as key in std::unordered_map // For storing as key in std::unordered_map
template<> template<>
struct hash<share_data::StoredObject> { struct hash<effil::StoredObject> {
std::size_t operator()(const share_data::StoredObject &object) const noexcept { std::size_t operator()(const effil::StoredObject &object) const noexcept {
return object.hash(); return object.hash();
} }
}; };

View File

@ -1,6 +1,6 @@
#include "threading.h" #include "threading.h"
namespace threading { namespace effil {
LuaThread::LuaThread(const sol::function& function, const sol::variadic_args& args) noexcept { LuaThread::LuaThread(const sol::function& function, const sol::variadic_args& args) noexcept {
// 1. Dump function to string // 1. Dump function to string
@ -15,7 +15,7 @@ LuaThread::LuaThread(const sol::function& function, const sol::variadic_args& ar
sol::lib::package, sol::lib::io, sol::lib::os sol::lib::package, sol::lib::io, sol::lib::os
); );
getUserType(*p_state_); getUserType(*p_state_);
share_data::SharedTable::getUserType(*p_state_); effil::SharedTable::getUserType(*p_state_);
// 3. Save parameters // 3. Save parameters
storeArgs(args); storeArgs(args);
@ -28,7 +28,7 @@ LuaThread::LuaThread(const sol::function& function, const sol::variadic_args& ar
void LuaThread::storeArgs(const sol::variadic_args &args) noexcept { void LuaThread::storeArgs(const sol::variadic_args &args) noexcept {
p_arguments_ = std::make_shared<std::vector<sol::object>>(); p_arguments_ = std::make_shared<std::vector<sol::object>>();
for(auto iter = args.begin(); iter != args.end(); iter++) { for(auto iter = args.begin(); iter != args.end(); iter++) {
share_data::StoredObject store(iter->get<sol::object>()); effil::StoredObject store(iter->get<sol::object>());
p_arguments_->push_back(store.unpack(sol::this_state{p_state_->lua_state()})); p_arguments_->push_back(store.unpack(sol::this_state{p_state_->lua_state()}));
} }
} }
@ -78,4 +78,4 @@ sol::object LuaThread::getUserType(sol::state_view &lua) noexcept
return sol::stack::pop<sol::object>(lua); return sol::stack::pop<sol::object>(lua);
} }
} // threading } // effil

View File

@ -8,7 +8,7 @@
#include <sstream> #include <sstream>
#include <thread> #include <thread>
namespace threading { namespace effil {
class LuaThread { class LuaThread {
public: public:
@ -30,4 +30,4 @@ private:
std::shared_ptr<std::vector<sol::object>> p_arguments_; std::shared_ptr<std::vector<sol::object>> p_arguments_;
}; };
} // threading } // effil

View File

@ -4,7 +4,7 @@
#include <thread> #include <thread>
using namespace share_data; using namespace effil;
namespace { namespace {