workPool: don't use std::function
it's kinda slow
This commit is contained in:
parent
084cbcb168
commit
9b276e80f8
7 changed files with 45 additions and 20 deletions
|
|
@ -197,6 +197,10 @@ struct DivDispatchContainer {
|
|||
bool lowQuality, dcOffCompensation;
|
||||
double rateMemory;
|
||||
|
||||
// used in multi-thread
|
||||
int cycles;
|
||||
unsigned int size;
|
||||
|
||||
void setRates(double gotRate);
|
||||
void setQuality(bool lowQual);
|
||||
void grow(size_t size);
|
||||
|
|
@ -215,7 +219,9 @@ struct DivDispatchContainer {
|
|||
lastAvail(0),
|
||||
lowQuality(false),
|
||||
dcOffCompensation(false),
|
||||
rateMemory(0.0) {
|
||||
rateMemory(0.0),
|
||||
cycles(0),
|
||||
size(0) {
|
||||
memset(bb,0,DIV_MAX_OUTPUTS*sizeof(blip_buffer_t*));
|
||||
memset(temp,0,DIV_MAX_OUTPUTS*sizeof(int));
|
||||
memset(prevSample,0,DIV_MAX_OUTPUTS*sizeof(int));
|
||||
|
|
|
|||
|
|
@ -1760,6 +1760,13 @@ void DivEngine::runMidiTime(int totalCycles) {
|
|||
}
|
||||
}
|
||||
|
||||
void _runDispatch1(void* d) {
|
||||
}
|
||||
|
||||
void _runDispatch2(void* d) {
|
||||
|
||||
}
|
||||
|
||||
void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsigned int size) {
|
||||
lastNBIns=inChans;
|
||||
lastNBOuts=outChans;
|
||||
|
|
@ -2066,9 +2073,11 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
// 5. tick the clock and fill buffers as needed
|
||||
if (cycles<runLeftG) {
|
||||
for (int i=0; i<song.systemLen; i++) {
|
||||
renderPool->push([this,size](void* d) {
|
||||
disCont[i].cycles=cycles;
|
||||
disCont[i].size=size;
|
||||
renderPool->push([](void* d) {
|
||||
DivDispatchContainer* dc=(DivDispatchContainer*)d;
|
||||
int total=(cycles*dc->runtotal)/(size<<MASTER_CLOCK_PREC);
|
||||
int total=(dc->cycles*dc->runtotal)/(dc->size<<MASTER_CLOCK_PREC);
|
||||
dc->acquire(dc->runPos,total);
|
||||
dc->runLeft-=total;
|
||||
dc->runPos+=total;
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ void DivWorkThread::run() {
|
|||
}
|
||||
}
|
||||
|
||||
bool DivWorkThread::assign(const std::function<void(void*)>& what, void* arg) {
|
||||
bool DivWorkThread::assign(void (*what)(void*), void* arg) {
|
||||
lock.lock();
|
||||
if (tasks.size()>=30) {
|
||||
lock.unlock();
|
||||
|
|
@ -105,7 +105,7 @@ void DivWorkThread::init(DivWorkPool* p) {
|
|||
thread=new std::thread(_workThread,this);
|
||||
}
|
||||
|
||||
void DivWorkPool::push(const std::function<void(void*)>& what, void* arg) {
|
||||
void DivWorkPool::push(void (*what)(void*), void* arg) {
|
||||
// if no work threads, just execute
|
||||
if (!threaded) {
|
||||
what(arg);
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@
|
|||
class DivWorkPool;
|
||||
|
||||
struct DivPendingTask {
|
||||
std::function<void(void*)> func;
|
||||
void (*func)(void*);
|
||||
void* funcArg;
|
||||
DivPendingTask(std::function<void(void*)> f, void* arg):
|
||||
DivPendingTask(void (*f)(void*), void* arg):
|
||||
func(f),
|
||||
funcArg(arg) {}
|
||||
DivPendingTask():
|
||||
|
|
@ -52,7 +52,7 @@ struct DivWorkThread {
|
|||
bool promiseAlreadySet;
|
||||
|
||||
void run();
|
||||
bool assign(const std::function<void(void*)>& what, void* arg);
|
||||
bool assign(void (*what)(void*), void* arg);
|
||||
void wait();
|
||||
bool busy();
|
||||
void finish();
|
||||
|
|
@ -82,7 +82,7 @@ class DivWorkPool {
|
|||
* push a new job to this work pool.
|
||||
* if all work threads are busy, this will block until one is free.
|
||||
*/
|
||||
void push(const std::function<void(void*)>& what, void* arg);
|
||||
void push(void (*what)(void*), void* arg);
|
||||
|
||||
/**
|
||||
* check whether this work pool is busy.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue