diff src/common/runtime.cpp @ 1098:a74672ba1320 minor

Merge in channels from love-experiments Rewritten love.thread and changed communication method from weird system before, to channels.
author Bart van Strien <bart.bes+projects@gmail.com>
date Wed, 04 Jul 2012 17:15:16 +0200
parents 86a44f2bc38f
children 7c7332becb70
line wrap: on
line diff
--- a/src/common/runtime.cpp	Wed Jul 04 14:41:03 2012 +0200
+++ b/src/common/runtime.cpp	Wed Jul 04 17:15:16 2012 +0200
@@ -25,7 +25,7 @@
 #include "Object.h"
 #include "Reference.h"
 #include "StringMap.h"
-#include "thread/threads.h"
+#include <thread/threads.h>
 
 // STD
 #include <iostream>
@@ -35,7 +35,6 @@
 
 static thread::Mutex *gcmutex = 0;
 void *_gcmutex = 0;
-unsigned int _gcthread = 0;
 /**
  * Called when an object is collected. The object is released
  * once in this function, possibly deleting it.
@@ -44,7 +43,7 @@
 {
 	if (!gcmutex)
 	{
-		gcmutex = new thread::Mutex();
+		gcmutex = thread::newMutex();
 		_gcmutex = (void *) gcmutex;
 	}
 	Proxy *p = (Proxy *)lua_touserdata(L, 1);
@@ -52,7 +51,6 @@
 	if (p->own)
 	{
 		thread::Lock lock(gcmutex);
-		_gcthread = thread::ThreadBase::threadId();
 		t->release();
 	}
 	return 0;
@@ -118,6 +116,13 @@
 	return b;
 }
 
+std::string luax_tostring(lua_State *L, int idx)
+{
+	size_t len;
+	const char *str = lua_tolstring(L, idx, &len);
+	return std::string(str, len);
+}
+
 std::string luax_checkstring(lua_State *L, int idx)
 {
 	size_t len;
@@ -462,6 +467,7 @@
 
 	// Thread
 	{"Thread", THREAD_THREAD_ID},
+	{"Channel", THREAD_CHANNEL_ID},
 
 	// The modules themselves. Only add abstracted modules here.
 	{"filesystem", MODULE_FILESYSTEM_ID},