mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Improved performance of ImageData:mapPixel (now up to 2x as fast as in 0.8.0!); love.graphics.newImage, Image:refresh, love.window.setIcon, and ImageRasterizers now prevent other threads from modifying the ImageData used in those functions until they're done accessing it
This commit is contained in:
@@ -42,6 +42,37 @@ Lock::~Lock()
|
||||
mutex->unlock();
|
||||
}
|
||||
|
||||
EmptyLock::EmptyLock()
|
||||
: mutex(0)
|
||||
{
|
||||
}
|
||||
|
||||
EmptyLock::~EmptyLock()
|
||||
{
|
||||
if (mutex)
|
||||
mutex->unlock();
|
||||
}
|
||||
|
||||
void EmptyLock::setLock(Mutex *m)
|
||||
{
|
||||
if (mutex)
|
||||
mutex->unlock();
|
||||
|
||||
mutex = m;
|
||||
|
||||
if (mutex)
|
||||
mutex->lock();
|
||||
}
|
||||
|
||||
void EmptyLock::setLock(Mutex &m)
|
||||
{
|
||||
if (mutex)
|
||||
mutex->unlock();
|
||||
|
||||
mutex = &m;
|
||||
mutex->lock();
|
||||
}
|
||||
|
||||
Threadable::Threadable()
|
||||
{
|
||||
owner = newThread(this);
|
||||
|
||||
@@ -59,6 +59,19 @@ private:
|
||||
Mutex *mutex;
|
||||
};
|
||||
|
||||
class EmptyLock
|
||||
{
|
||||
public:
|
||||
EmptyLock();
|
||||
~EmptyLock();
|
||||
|
||||
void setLock(Mutex *m);
|
||||
void setLock(Mutex &m);
|
||||
|
||||
private:
|
||||
Mutex *mutex;
|
||||
};
|
||||
|
||||
class Threadable
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user