Merge in channels from love-experiments

Rewritten love.thread and changed communication
method from weird system before, to channels.

--HG--
branch : minor
This commit is contained in:
Bart van Strien
2012-07-04 17:15:16 +02:00
parent e8ee7671c3
commit 399a6a6614
41 changed files with 1192 additions and 1580 deletions
+39 -16
View File
@@ -20,28 +20,51 @@
#include "threads.h"
#if LOVE_THREADS == LOVE_THREADS_POSIX
# include "posix/threads.cpp"
#elif LOVE_THREADS == LOVE_THREADS_WIN32
# include "win32/threads.cpp"
#elif LOVE_THREADS == LOVE_THREADS_SDL
# include "sdl/threads.cpp"
#endif
namespace love
{
namespace thread
{
const char *threadAPI()
Lock::Lock(Mutex *m)
: mutex(m)
{
#if LOVE_THREADS == LOVE_THREADS_POSIX
return "posix";
#elif LOVE_THREADS == LOVE_THREADS_WIN32
return "win32";
#elif LOVE_THREADS == LOVE_THREADS_SDL
return "sdl";
#endif
mutex->lock();
}
Lock::Lock(Mutex &m)
: mutex(&m)
{
mutex->lock();
}
Lock::~Lock()
{
mutex->unlock();
}
Threadable::Threadable()
{
owner = newThread(this);
}
Threadable::~Threadable()
{
delete owner;
}
bool Threadable::start()
{
return owner->start();
}
void Threadable::wait()
{
owner->wait();
}
void Threadable::kill()
{
owner->kill();
}
} // thread