parent
9d18793544
commit
e4652ade19
@ -1,89 +0,0 @@
|
||||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlinesLeft: false
|
||||
AlignOperands: false
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: true
|
||||
ColumnLimit: 120
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 8
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
- Regex: '^(<|"(gtest|isl|json)/)'
|
||||
Priority: 3
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
IndentCaseLabels: true
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Left
|
||||
ReflowComments: true
|
||||
SortIncludes: false
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Cpp11
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
...
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
||||
.work_dir
|
||||
build
|
||||
*.user
|
||||
cmake-*
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -4,9 +4,6 @@
|
||||
[submodule "libs/gtest"]
|
||||
path = libs/gtest
|
||||
url = https://github.com/google/googletest.git
|
||||
[submodule "libs/luaunit"]
|
||||
path = libs/luaunit
|
||||
url = https://github.com/bluebird75/luaunit
|
||||
[submodule "libs/u-test"]
|
||||
path = libs/u-test
|
||||
url = https://github.com/IUdalov/u-test.git
|
||||
|
||||
@ -13,9 +13,6 @@ FILE(GLOB LUA_SOURCES src/lua/*.lua)
|
||||
if(APPLE)
|
||||
# Supress warning CMP0042
|
||||
set(CMAKE_MACOSX_RPATH 1)
|
||||
set(LIBRARY_EXT dylib)
|
||||
else()
|
||||
set(LIBRARY_EXT so)
|
||||
endif()
|
||||
|
||||
add_library(effil SHARED ${SOURCES})
|
||||
@ -38,13 +35,6 @@ include_directories(${GTEST_DIR}/include ${GTEST_DIR})
|
||||
add_executable(tests ${TEST_SOURCES} ${GTEST_DIR}/src/gtest-all.cc)
|
||||
target_link_libraries(tests effil ${LUA_LIBRARY})
|
||||
|
||||
#----------
|
||||
# FORMAT -
|
||||
#----------
|
||||
add_custom_target( format
|
||||
COMMAND clang-format -i ${TEST_SOURCES} ${SOURCES}
|
||||
)
|
||||
|
||||
#----------
|
||||
# INSTALL -
|
||||
#----------
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
# Effil
|
||||
[](https://travis-ci.org/loud-hound/effil)
|
||||
[](https://ci.appveyor.com/project/loud-hound/effil/branch/master)
|
||||
[](http://effil.readthedocs.io/en/latest/?badge=latest)
|
||||
|
||||
Effil is a lua module for multithreading support.
|
||||
It allows to spawn native threads and safe data exchange.
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
# Effil
|
||||
Threading library for Lua. Written in C++ with great help of [sol2](https://github.com/ThePhD/sol2).
|
||||
@ -1 +0,0 @@
|
||||
Subproject commit d2f1ffa86582d51b77dc29b1f7216e75fe2bc6d0
|
||||
@ -7,7 +7,8 @@ namespace effil {
|
||||
void Channel::getUserType(sol::state_view& lua) {
|
||||
sol::usertype<Channel> type("new", sol::no_constructor,
|
||||
"push", &Channel::push,
|
||||
"pop", &Channel::pop
|
||||
"pop", &Channel::pop,
|
||||
"size", &Channel::size
|
||||
);
|
||||
sol::stack::push(lua, type);
|
||||
sol::stack::pop<sol::object>(lua);
|
||||
@ -65,4 +66,9 @@ StoredArray Channel::pop(const sol::optional<int>& duration,
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t Channel::size() {
|
||||
std::lock_guard<std::mutex> lock(data_->lock_);
|
||||
return data_->channel_.size();
|
||||
}
|
||||
|
||||
} // namespace effil
|
||||
|
||||
@ -16,6 +16,7 @@ public:
|
||||
StoredArray pop(const sol::optional<int>& duration,
|
||||
const sol::optional<std::string>& period);
|
||||
|
||||
size_t size();
|
||||
protected:
|
||||
struct SharedData {
|
||||
std::mutex lock_;
|
||||
|
||||
@ -62,11 +62,10 @@ extern "C" int luaopen_libeffil(lua_State* L) {
|
||||
"table", createTable,
|
||||
"rawset", SharedTable::luaRawSet,
|
||||
"rawget", SharedTable::luaRawGet,
|
||||
"size", SharedTable::luaSize,
|
||||
"table_size", SharedTable::luaSize,
|
||||
"setmetatable", SharedTable::luaSetMetatable,
|
||||
"getmetatable", SharedTable::luaGetMetatable,
|
||||
"G", sol::make_object(lua, globalTable),
|
||||
"getmetatable", SharedTable::luaGetMetatable,
|
||||
"gc", GC::getLuaApi(lua),
|
||||
"channel", createChannel,
|
||||
"userdata_type", userdataType
|
||||
|
||||
@ -17,7 +17,6 @@ local api = {
|
||||
thread_id = capi.thread_id,
|
||||
sleep = capi.sleep,
|
||||
yield = capi.yield,
|
||||
size = capi.size,
|
||||
rawget = capi.rawget,
|
||||
rawset = capi.rawset,
|
||||
setmetatable = capi.setmetatable,
|
||||
@ -36,6 +35,17 @@ api.type = function (something)
|
||||
end
|
||||
end
|
||||
|
||||
api.size = function (something)
|
||||
local t = api.type(something)
|
||||
if t == "effil.table" then
|
||||
return capi.table_size(something)
|
||||
elseif t == "effil.channel" then
|
||||
return something:size()
|
||||
else
|
||||
error("Unsupported type " .. t .. " for effil.size()")
|
||||
end
|
||||
end
|
||||
|
||||
local function run_thread(config, f, ...)
|
||||
return capi.thread(config.path, config.cpath, config.step, f, ...)
|
||||
end
|
||||
|
||||
@ -7,11 +7,14 @@ test.channel.capacity_usage = function()
|
||||
|
||||
test.is_true(chan:push(14))
|
||||
test.is_true(chan:push(88))
|
||||
test.equal(chan:size(), 2)
|
||||
|
||||
test.is_false(chan:push(1488))
|
||||
|
||||
test.equal(chan:pop(), 14)
|
||||
test.equal(chan:pop(), 88)
|
||||
test.is_nil(chan:pop(0))
|
||||
test.equal(chan:size(), 0)
|
||||
|
||||
test.is_true(chan:push(14, 88), true)
|
||||
local ret1, ret2 = chan:pop()
|
||||
|
||||
14
tests/lua/size.lua
Normal file
14
tests/lua/size.lua
Normal file
@ -0,0 +1,14 @@
|
||||
require "bootstrap-tests"
|
||||
|
||||
test.size = function()
|
||||
local st = effil.table()
|
||||
st[0] = 1
|
||||
st[1] = 0
|
||||
|
||||
local chan = effil.channel()
|
||||
chan:push(0)
|
||||
chan:push(2)
|
||||
|
||||
test.equal(effil.size(st), 2)
|
||||
test.equal(effil.size(chan), 2)
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user