Commit Graph

21 Commits

Author SHA1 Message Date
Alex Szpakowski e71f27c65d Move Lua wrapper code for Variants out of the Variant class file. 2020-02-28 21:54:03 -04:00
Bart van Strien 09c1259857 Add optional timeout values to Channel:supply and Channel:demand (resolves #1344)
--HG--
branch : minor
2017-09-11 13:40:21 +02:00
Bart van Strien 5ddc89a033 Added cycle detection to Variant
We accidentally enabled nested tables previously, and now it errors properly when the tables contain cycles. Before you'd get (or at least I got) a nice lua stack overflow error.

--HG--
branch : minor
2017-08-30 13:07:57 +02:00
Bart van Strien 9f6aa716fa Pass Type to luax_register_type by pointer instead of reference
Since the type is passed to va_start, and apparently that's undefined behaviour if it's a reference.

<Textmode> the best kind of behavior

--HG--
branch : dynamiccore2
2016-11-14 21:51:47 +01:00
Bart van Strien d967a755e5 Make love::Type handle type names
TODO: Fix undefined behaviour in luax_register_type, you can't use a va_list after a reference type

--HG--
branch : dynamiccore2
2016-11-14 21:06:53 +01:00
Bart van Strien 7dd960619d Automatically deduce the type in luax_checktype, luax_getmodule, luax_optmodule and luax_totype
--HG--
branch : dynamiccore2
2016-11-13 17:13:40 +01:00
Bart van Strien c761202486 Build type information on first use (load-time), instead of using a hardcoded list
--HG--
branch : dynamiccore2
2016-11-13 16:38:57 +01:00
Alex Szpakowski 293bc79b97 Merge default into minor
--HG--
branch : minor
2016-03-12 22:04:07 -04:00
Alex Szpakowski d0c0240e09 Very minor channel / variant performance improvements and cleanup. 2016-03-12 19:11:03 -04:00
Alex Szpakowski 140faf0cae Channel:push now returns an id value. Added Channel:hasRead(id), which returns true if the value that the id represents has already been popped, demanded, or cleared from the Channel. Resolves issue #1104.
--HG--
branch : minor
2016-03-09 22:04:14 -04:00
Alex Szpakowski 23fcaec89f The Variant class is now meant to be used on the stack instead of allocated on the heap. As a result (and because of related changes), performance of Channels has roughly doubled when pushing and popping most types. 2016-02-14 16:39:32 -04:00
Alex Szpakowski 2c4e713114 Imported some of the dynamiccore branch from love-experiments:
- Type names for love's Lua objects are specified as an argument to luax_register_type, rather than being statically defined in an array.

- luax_register_type takes a variable number of method array arguments, for registering superclass methods without copying them into the subclass' method array.

Also removed most of the header declarations for wrapper functions.
2015-11-29 20:38:12 -04:00
Alex Szpakowski 289eeb4fe0 Added Channel:performAtomic(func, ...). Resolves issue #1034.
performAtomic calls the function and passes the Channel as the first argument, plus any additional specified arguments. The called function should do as little work as possible.

To other threads, all methods for that Channel are executed in a single step inside the function. This can prevent a large number of potiential race conditions.

Example:

-- main.lua:
local function set(channel, value)
    channel:clear()
    channel:push(value)
    return "set value"
end

assert(channel:performAtomic(set, 1) == "set value")

-- thread.lua
while true do
    assert(channel:peek() == 1)
end
2015-04-24 23:53:28 -03:00
Alex Szpakowski 2f419c1c83 Replaced most cases of type bits and type name strings in love's Lua wrapper code with type id's.
--HG--
branch : minor
2015-03-01 18:32:41 -04:00
Alex Szpakowski 8ac288876d Added Thread:isRunning 2013-07-16 00:18:04 -03:00
Alex Szpakowski 35b4f03411 Fixed thread:start crashing with nil arguments 2013-07-10 17:41:54 -03:00
Alex Szpakowski 4c616e409b Renamed ParticleSystem:count, Channel:count, and all getNum* functions to get*Count (issue #602) 2013-05-03 04:04:44 -03:00
Alex Szpakowski f0860a488d Added argument type checking to Channel:push (nil now errors instead of crashing) 2013-03-30 14:42:09 -03:00
Bart van Strien c7c5d0ed6b Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Also, this is a giant commit because of the official Code Style (tm) was applied.

--HG--
branch : minor
2013-01-30 17:15:12 +01:00
Bart van Strien be2363fc00 Add Channel:supply(), a blocking version of Channel:push()
--HG--
branch : minor
2013-01-27 20:04:16 +01:00
Bart van Strien 399a6a6614 Merge in channels from love-experiments
Rewritten love.thread and changed communication
method from weird system before, to channels.

--HG--
branch : minor
2012-07-04 17:15:16 +02:00