Skip to content
Snippets Groups Projects
Commit d375021c authored by dg's avatar dg
Browse files

removed lua lanes, was not used anyway

git-svn-id: http://svn.net-core.org/repos/t-engine4@6579 51575b47-30f0-44d4-a5cc-537603b46e54
parent bc69c624
No related branches found
No related tags found
No related merge requests found
......@@ -34,7 +34,7 @@ project "TEngine"
language "C"
targetname("t-engine")
files { "../src/*.c", }
links { "physfs", "lua".._OPTIONS.lua, "fov", "luasocket", "luaprofiler", "lualanes", "lpeg", "tcodimport", "lxp", "expatstatic", "luamd5", "luazlib", "luabitop", "te4-bzip" }
links { "physfs", "lua".._OPTIONS.lua, "fov", "luasocket", "luaprofiler", "lpeg", "tcodimport", "lxp", "expatstatic", "luamd5", "luazlib", "luabitop", "te4-bzip" }
defines { "_DEFAULT_VIDEOMODE_FLAGS_='SDL_HWSURFACE|SDL_DOUBLEBUF'" }
defines { [[TENGINE_HOME_PATH='".t-engine"']], "TE4CORE_VERSION="..TE4CORE_VERSION }
......@@ -366,13 +366,6 @@ project "luaprofiler"
files { "../src/luaprofiler/*.c", }
project "lualanes"
kind "StaticLib"
language "C"
targetname "lualanes"
files { "../src/lualanes/*.c", }
project "tcodimport"
kind "StaticLib"
language "C"
......
......@@ -19,7 +19,6 @@
-- darkgod@te4.org
require "engine.class"
local lanes = require "lanes"
local Dialog = require "engine.ui.Dialog"
local Savefile = require "engine.Savefile"
require "engine.PlayerProfile"
......@@ -826,13 +825,3 @@ function _M:loadSavefileDescription(dir)
return ls
end
end
--- Loads a list of modules from te4.org/modules.lualist
-- Calling this function starts a background thread, which can be waited on by the returned lina object
-- @param src the url to load the list from, if nil it will default to te4.org
-- @return a linda object (see lua lanes documentation) which should be waited upon like this <code>local mylist = l:receive("moduleslist")</code>. Also returns a thread handle
function _M:loadRemoteList(src)
local DownloadDialog = require "engine.dialogs.DownloadDialog"
local d = DownloadDialog.new("Fetching updates", "http://te4.org/dl/t-engine/t-engine4-windows-1.0.0beta21.zip")
d:startDownload()
end
......@@ -21,7 +21,6 @@ require "engine.class"
local http = require "socket.http"
local url = require "socket.url"
local ltn12 = require "ltn12"
local lanes = require "lanes"
local Dialog = require "engine.ui.Dialog"
local UserChat = require "engine.UserChat"
require "Json2"
......
-- TE4 - T-Engine 4
-- Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
require "engine.class"
local dispatch = require "dispatch"
local Dialog = require "engine.ui.Dialog"
local Textzone = require "engine.ui.Textzone"
module(..., package.seeall, class.inherit(Dialog))
function _M:init(title, url, on_chunk, on_finish, on_error)
self.url = url
self.received = 0
self.on_chunk = on_chunk
self.on_finish = on_finish
self.on_error = on_error
Dialog.init(self, title or "Download", 1, 1)
local desc = Textzone.new{text="Downloading from "..url, width=400, auto_height=true}
self:loadUI{
{left=0, top=0, ui=desc},
}
self:setupUI(true, true)
self.key:addBinds{
EXIT = function() game:unregisterDialog(self) end,
}
end
function _M:startDownload()
--[[
local l = lanes.linda()
function list_handler(src)
local http = require "socket.http"
local ltn12 = require "ltn12"
local size = 0
http.TIMEOUT = 1200
http.request{url = src, sink = function(chunk, err)
if err then
l:send(0, "received", {error=err})
end
if chunk then
size = size + #chunk
l:send(0, "received", {size=size, chunk=chunk})
end
return 1
end}
l:send("final", true)
end
self.th = lanes.gen("*", list_handler)(self.url)
self.linda = l
-- ]]
--[[
local co = coroutine.create(function()
local http = require "socket.http"
local ltn12 = require "ltn12"
local size = 0
http.TIMEOUT = 1200
print("Downloading from", self.url)
http.request{url = self.url, sink = function(chunk, err)
coroutine.yield()
return 1
end}
game:unregisterDialog(self)
end)
game:registerCoroutine("download module list", co)
]]
local http = require "socket.http"
local ltn12 = require "ltn12"
local handler = dispatch.newhandler("coroutine")
local done = false
handler:start(function()
print("plop")
http.request{
url = self.url,
sink = function(chunk, err) print("=====") end,
create = handler.tcp,
}
done = true
end)
while not done do
handler:step()
coroutine.yield()
end
end
--
-- KEEPER.LUA
--
-- Keeper state logic
--
-- This code is read in for each "keeper state", which are the hidden, inter-
-- mediate data stores used by Lanes inter-state communication objects.
--
-- Author: Asko Kauppi <akauppi@gmail.com>
--
--[[
===============================================================================
Copyright (C) 2008 Asko Kauppi <akauppi@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===============================================================================
]]--
-- unique key instead of 'nil' in queues
--
assert( nil_sentinel )
-- We only need to have base and table libraries (and io for debugging)
--
local table_remove= assert( table.remove )
local table_concat= assert( table.concat )
local function WR(...)
if io then
io.stderr:write( table_concat({...},'\t').."\n" )
end
end
-----
-- Actual data store
--
-- { [linda_deep_ud]= { key= val [, ...] }
-- ...
-- }
--
local _data= {}
-----
-- Entries queued for use when the existing 'data[ud][key]' entry is consumed.
--
-- { [linda_deep_ud]= { key= { val [, ... } [, ...] }
-- ...
-- }
--
local _incoming= {}
-----
-- Length limits (if any) for queues
--
-- 0: don't queue values at all; ':send()' waits if the slot is not vacant
-- N: allow N values to be queued (slot itself + N-1); wait if full
-- nil: no limits, '_incoming' may grow endlessly
--
local _limits= {}
-----
-- data_tbl, incoming_tbl, limits_tbl = tables( linda_deep_ud )
--
-- Gives appropriate tables for a certain Linda (creates them if needed)
--
local function tables( ud )
-- tables are created either all or nothing
--
if not _data[ud] then
_data[ud]= {}
_incoming[ud]= {}
_limits[ud]= {}
end
return _data[ud], _incoming[ud], _limits[ud]
end
local function DEBUG(title,ud,key)
assert( title and ud and key )
local data,incoming,_= tables(ud)
local s= tostring(data[key])
for _,v in ipairs( incoming[key] or {} ) do
s= s..", "..tostring(v)
end
WR( "*** "..title.." ("..tostring(key).."): ", s )
end
-----
-- bool= send( linda_deep_ud, key, ... )
--
-- Send new data (1..N) to 'key' slot. This send is atomic; all the values
-- end up one after each other (this is why having possibility for sending
-- multiple values in one call is deemed important).
--
-- If the queue has a limit, values are sent only if all of them fit in.
--
-- Returns: 'true' if all the values were placed
-- 'false' if sending would exceed the queue limit (wait & retry)
--
function send( ud, key, ... )
local data,incoming,limits= tables(ud)
local n= select('#',...)
if n==0 then return true end -- nothing to send
-- Initialize queue for all keys that have been used with ':send()'
--
if incoming[key]==nil then
incoming[key]= {}
end
local len= data[key] and 1+#incoming[key] or 0
local m= limits[key]
if m and len+n > m then
return false -- would exceed the limit; try again later
end
for i=1,n do
local val= select(i,...)
-- 'nil' in the data replaced by sentinel
if val==nil then
val= nil_sentinel
end
if len==0 then
data[key]= val
len= 1
else
incoming[key][len]= val
len= len+1
end
end
return true
end
-----
-- [val, key]= receive( linda_deep_ud, key [, ...] )
--
-- Read any of the given keys, consuming the data found. Keys are read in
-- order.
--
function receive( ud, ... )
local data,incoming,_= tables(ud)
for i=1,select('#',...) do
local key= select(i,...)
local val= data[key]
if val~=nil then
if incoming[key] and incoming[key][1]~=nil then
-- pop [1] from 'incoming[key]' into the actual slot
data[key]= table_remove( incoming[key], 1 )
else
data[key]= nil -- empty the slot
end
if val==nil_sentinel then
val= nil
end
return val, key
end
end
--return nil
end
-----
-- = limit( linda_deep_ud, key, uint )
--
function limit( ud, key, n )
local _,_,limits= tables(ud)
limits[key]= n
end
-----
-- void= set( linda_deep_ud, key, [val] )
--
function set( ud, key, val )
local data,incoming,_= tables(ud)
-- Setting a key to 'nil' really clears it; only queing uses sentinels.
--
data[key]= val
incoming[key]= nil
end
-----
-- [val]= get( linda_deep_ud, key )
--
function get( ud, key )
local data,_,_= tables(ud)
local val= data[key]
if val==nil_sentinel then
val= nil
end
return val
end
-----
-- void= clear( linda_deep_ud )
--
-- Clear the data structures used for a Linda (at its destructor)
--
function clear( ud )
_data[ud]= nil
_incoming[ud]= nil
_limits[ud]= nil
end
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* THREADING.H
*/
#ifndef THREADING_H
#define THREADING_H
/* Platform detection
*/
#ifdef _WIN32_WCE
#define PLATFORM_POCKETPC
#elif (defined _WIN32)
#define PLATFORM_WIN32
#elif (defined __linux__)
#define PLATFORM_LINUX
#elif (defined __APPLE__) && (defined __MACH__)
#define PLATFORM_OSX
#elif (defined __NetBSD__) || (defined __FreeBSD__) || (defined BSD)
#define PLATFORM_BSD
#elif (defined __QNX__)
#define PLATFORM_QNX
#elif (defined __CYGWIN__)
#define PLATFORM_CYGWIN
#else
#error "Unknown platform!"
#endif
typedef int bool_t;
#ifndef FALSE
# define FALSE 0
# define TRUE 1
#endif
typedef unsigned int uint_t;
#if defined(PLATFORM_WIN32) && defined(__GNUC__)
/* MinGW with MSVCR80.DLL */
/* Do this BEFORE including time.h so that it is declaring _mktime32()
* as it would have declared mktime().
*/
//# define mktime _mktime32
#endif
#include <time.h>
/* Note: ERROR is a defined entity on Win32
*/
enum e_status { PENDING, RUNNING, WAITING, DONE, ERROR_ST, CANCELLED };
/*---=== Locks & Signals ===---
*/
#if (defined PLATFORM_WIN32) || (defined PLATFORM_POCKETPC)
#define WIN32_LEAN_AND_MEAN
// 'SignalObjectAndWait' needs this (targets Windows 2000 and above)
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <process.h>
// MSDN: http://msdn2.microsoft.com/en-us/library/ms684254.aspx
//
// CRITICAL_SECTION can be used for simple code protection. Mutexes are
// needed for use with the SIGNAL system.
//
#define MUTEX_T HANDLE
void MUTEX_INIT( MUTEX_T *ref );
#define MUTEX_RECURSIVE_INIT(ref) MUTEX_INIT(ref) /* always recursive in Win32 */
void MUTEX_FREE( MUTEX_T *ref );
void MUTEX_LOCK( MUTEX_T *ref );
void MUTEX_UNLOCK( MUTEX_T *ref );
typedef unsigned THREAD_RETURN_T;
#define SIGNAL_T HANDLE
#define YIELD() Sleep(0)
#else
// PThread (Linux, OS X, ...)
//
#include <pthread.h>
#ifdef PLATFORM_LINUX
# define _MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP
#else
/* OS X, ... */
# define _MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE
#endif
#define MUTEX_T pthread_mutex_t
#define MUTEX_INIT(ref) pthread_mutex_init(ref,NULL)
#define MUTEX_RECURSIVE_INIT(ref) \
{ pthread_mutexattr_t a; pthread_mutexattr_init( &a ); \
pthread_mutexattr_settype( &a, _MUTEX_RECURSIVE ); \
pthread_mutex_init(ref,&a); pthread_mutexattr_destroy( &a ); \
}
#define MUTEX_FREE(ref) pthread_mutex_destroy(ref)
#define MUTEX_LOCK(ref) pthread_mutex_lock(ref)
#define MUTEX_UNLOCK(ref) pthread_mutex_unlock(ref)
typedef void * THREAD_RETURN_T;
typedef pthread_cond_t SIGNAL_T;
void SIGNAL_ONE( SIGNAL_T *ref );
// Yield is non-portable:
//
// OS X 10.4.8/9 has pthread_yield_np()
// Linux 2.4 has pthread_yield() if _GNU_SOURCE is #defined
// FreeBSD 6.2 has pthread_yield()
// ...
//
#ifdef PLATFORM_OSX
#define YIELD() pthread_yield_np()
#else
#define YIELD() pthread_yield()
#endif
#endif
void SIGNAL_INIT( SIGNAL_T *ref );
void SIGNAL_FREE( SIGNAL_T *ref );
void SIGNAL_ALL( SIGNAL_T *ref );
/*
* 'time_d': <0.0 for no timeout
* 0.0 for instant check
* >0.0 absolute timeout in secs + ms
*/
typedef double time_d;
time_d now_secs(void);
time_d SIGNAL_TIMEOUT_PREPARE( double rel_secs );
bool_t SIGNAL_WAIT( SIGNAL_T *ref, MUTEX_T *mu, time_d timeout );
/*---=== Threading ===---
*/
#if (defined PLATFORM_WIN32) || (defined PLATFORM_POCKETPC)
typedef HANDLE THREAD_T;
//
void THREAD_CREATE( THREAD_T *ref,
THREAD_RETURN_T (__stdcall *func)( void * ),
void *data, int prio /* -3..+3 */ );
# define THREAD_PRIO_MIN (-3)
# define THREAD_PRIO_MAX (+3)
#else
/* Platforms that have a timed 'pthread_join()' can get away with a simpler
* implementation. Others will use a condition variable.
*/
# ifdef USE_PTHREAD_TIMEDJOIN
# ifdef PLATFORM_OSX
# error "No 'pthread_timedjoin()' on this system"
# else
/* Linux, ... */
# define PTHREAD_TIMEDJOIN pthread_timedjoin_np
# endif
# endif
typedef pthread_t THREAD_T;
void THREAD_CREATE( THREAD_T *ref,
THREAD_RETURN_T (*func)( void * ),
void *data, int prio /* -2..+2 */ );
# if defined(PLATFORM_LINUX)
volatile bool_t sudo;
# ifdef LINUX_SCHED_RR
# define THREAD_PRIO_MIN (sudo ? -2 : 0)
# else
# define THREAD_PRIO_MIN (0)
# endif
# define THREAD_PRIO_MAX (sudo ? +2 : 0)
# else
# define THREAD_PRIO_MIN (-2)
# define THREAD_PRIO_MAX (+2)
# endif
#endif
/*
* Win32 and PTHREAD_TIMEDJOIN allow waiting for a thread with a timeout.
* Posix without PTHREAD_TIMEDJOIN needs to use a condition variable approach.
*/
#if (defined PLATFORM_WIN32) || (defined PLATFORM_POCKETPC) || (defined PTHREAD_TIMEDJOIN)
bool_t THREAD_WAIT( THREAD_T *ref, double secs );
#else
bool_t THREAD_WAIT( THREAD_T *ref, SIGNAL_T *signal_ref, MUTEX_T *mu_ref, volatile enum e_status *st_ref, double secs );
#endif
void THREAD_KILL( THREAD_T *ref );
#endif
// THREADING_H
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment