mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
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:
@@ -23,6 +23,8 @@
|
||||
|
||||
#include "sound/Decoder.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace audio
|
||||
@@ -34,9 +36,16 @@ Audio::PoolThread::PoolThread(Pool *pool)
|
||||
: pool(pool)
|
||||
, finish(false)
|
||||
{
|
||||
mutex = thread::newMutex();
|
||||
}
|
||||
|
||||
void Audio::PoolThread::main()
|
||||
Audio::PoolThread::~PoolThread()
|
||||
{
|
||||
delete mutex;
|
||||
}
|
||||
|
||||
|
||||
void Audio::PoolThread::threadFunction()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
@@ -59,7 +68,6 @@ void Audio::PoolThread::setFinish()
|
||||
finish = true;
|
||||
}
|
||||
|
||||
|
||||
Audio::Audio() : distanceModel(DISTANCE_INVERSE_CLAMPED)
|
||||
{
|
||||
// Passing zero for default device.
|
||||
|
||||
@@ -109,7 +109,7 @@ private:
|
||||
// The Pool.
|
||||
Pool *pool;
|
||||
|
||||
class PoolThread: public thread::ThreadBase
|
||||
class PoolThread: public thread::Threadable
|
||||
{
|
||||
protected:
|
||||
Pool *pool;
|
||||
@@ -120,13 +120,13 @@ private:
|
||||
volatile bool finish;
|
||||
|
||||
// finish lock
|
||||
thread::Mutex mutex;
|
||||
|
||||
virtual void main();
|
||||
thread::Mutex *mutex;
|
||||
|
||||
public:
|
||||
PoolThread(Pool *pool);
|
||||
~PoolThread();
|
||||
void setFinish();
|
||||
void threadFunction();
|
||||
};
|
||||
|
||||
PoolThread *poolThread;
|
||||
|
||||
@@ -35,7 +35,7 @@ Pool::Pool()
|
||||
alGenSources(NUM_SOURCES, sources);
|
||||
|
||||
// Create the mutex.
|
||||
mutex = new thread::Mutex();
|
||||
mutex = thread::newMutex();
|
||||
|
||||
if (alGetError() != AL_NO_ERROR)
|
||||
throw love::Exception("Could not generate sources.");
|
||||
|
||||
Reference in New Issue
Block a user