mirror of
https://github.com/love2d/love.git
synced 2026-08-15 07:41:11 +02:00
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
This commit is contained in:
@@ -36,8 +36,9 @@ int w_Channel_push(lua_State *L)
|
||||
Variant var;
|
||||
if (!Variant::fromLua(L, 2, &var))
|
||||
return luaL_argerror(L, 2, "boolean, number, string, love type, or flat table expected");
|
||||
c->push(var);
|
||||
return 0;
|
||||
uint64 id = c->push(var);
|
||||
lua_pushnumber(L, (lua_Number) id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Channel_supply(lua_State *L)
|
||||
@@ -88,6 +89,14 @@ int w_Channel_getCount(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Channel_hasRead(lua_State *L)
|
||||
{
|
||||
Channel *c = luax_checkchannel(L, 1);
|
||||
uint64 id = (uint64) luaL_checknumber(L, 2);
|
||||
luax_pushboolean(L, c->hasRead(id));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Channel_clear(lua_State *L)
|
||||
{
|
||||
Channel *c = luax_checkchannel(L, 1);
|
||||
@@ -130,6 +139,7 @@ static const luaL_Reg w_Channel_functions[] =
|
||||
{ "demand", w_Channel_demand },
|
||||
{ "peek", w_Channel_peek },
|
||||
{ "getCount", w_Channel_getCount },
|
||||
{ "hasRead", w_Channel_hasRead },
|
||||
{ "clear", w_Channel_clear },
|
||||
{ "performAtomic", w_Channel_performAtomic },
|
||||
{ 0, 0 }
|
||||
|
||||
Reference in New Issue
Block a user