Compare commits
2 Commits
3d8b09167b
...
3cdd88a52d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3cdd88a52d | ||
![]() |
eca0ac6fe4 |
24
README.md
24
README.md
@ -17,9 +17,33 @@ Impotent is still work-in-progress:
|
|||||||
5. Most operators are still missing
|
5. Most operators are still missing
|
||||||
6. The user API is completely different from that of PoC Lua
|
6. The user API is completely different from that of PoC Lua
|
||||||
7. Being lock-free, tables are not split to "array" and "hash" parts
|
7. Being lock-free, tables are not split to "array" and "hash" parts
|
||||||
|
8. Userdata is not yet supported.
|
||||||
|
|
||||||
Impotent requires C11 and an architecture with 8-byte atomic operations, but otherwise it is completely cross-platform.
|
Impotent requires C11 and an architecture with 8-byte atomic operations, but otherwise it is completely cross-platform.
|
||||||
|
|
||||||
Performance-wise, it's surprisingly competitive with PoC Lua, considering how quickly it was made up to the point of writing this README (~2 weeks). By far the worst bottleneck is the GC, since it requires all threads and their heaps to synchronize.
|
Performance-wise, it's surprisingly competitive with PoC Lua, considering how quickly it was made up to the point of writing this README (~2 weeks). By far the worst bottleneck is the GC, since it requires all threads and their heaps to synchronize.
|
||||||
|
|
||||||
Certain Lua idioms become impossible under Impotent. For example the idiom of appending to tables (`t[#t + 1] = x`) isn't atomic, therefore `table.insert` should be used instead.
|
Certain Lua idioms become impossible under Impotent. For example the idiom of appending to tables (`t[#t + 1] = x`) isn't atomic, therefore `table.insert` should be used instead.
|
||||||
|
|
||||||
|
## Additions
|
||||||
|
|
||||||
|
Obviously, threading. Any thread can access any value from any other thread, including for reading or writing. Operations such as getting or setting are lock-free in the best case scenario, but other operations (such as the `#` operator) must lock the table temporarily.
|
||||||
|
|
||||||
|
Besides this, I have no intent to greatly deviate from standard Lua, to keep source-level compatibility as best I can. The only addition to the standard library is the `threads` global, with two methods as of now.
|
||||||
|
|
||||||
|
### `threads.run`
|
||||||
|
|
||||||
|
Runs a function in a newly created thread. Does not block the caller.
|
||||||
|
|
||||||
|
threads.run(function()
|
||||||
|
-- Do something expensive
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
### `threads.parallel`
|
||||||
|
|
||||||
|
Runs a function in n parallel threads. Blocks the caller until all threads finish.
|
||||||
|
|
||||||
|
threads.parallel(8, function()
|
||||||
|
-- Do something parallelizable.
|
||||||
|
end)
|
||||||
|
@ -4,7 +4,11 @@ for i = 50, 1, -1 do
|
|||||||
table.insert(t, 1, i)
|
table.insert(t, 1, i)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 50, 1, -1 do
|
for i = 50, 25, -1 do
|
||||||
|
table.insert(t, #t + 1, i)
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = 24, 1, -1 do
|
||||||
table.insert(t, i)
|
table.insert(t, i)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user