Esempio n. 1
0
void FilterGraph::buildFilterGraphFromLab(std::string labName)
{
    LabModel x = load(labName);
    BuildGraph buildGraph (*this, x, formatManager);
    BuildConnections buildConnections (*this, x, formatManager);
    
    std::thread clearThread([this](){clear();});
    
    clearThread.join();
    
    if (buildGraph.runThread()) {
        new_test("buildGraph thread completed");
    } else {
        new_test("buildGraph thread stopped");
    }
    
    if (buildConnections.runThread()) {
        qk_print("buildConnections thread completed");
        line_break();
    } else {
        qk_print("buildConnections thread stopped");
        line_break();
    }
    sendChangeMessage();
}
Esempio n. 2
0
void M2File::releaseExclusiveThreadCount(size_t recurseCounter)
{
    m_MapMutex.lock();
    recurseCount-=recurseCounter;
    if(!recurseCount)
    {
        clearThread(exclusiveOwner);
        pthread_cond_broadcast(&exclusiveChangeCondition);
    }
    else
    {
    }
    m_MapMutex.unlock();
}
Esempio n. 3
0
 void M2File_SetThreadMode(M2File* file, int threadMode)
 {
     if(file->currentThreadMode==2)
     {
         file->currentThreadMode = threadMode;
         //if changing out of thread 2 mode, zero the exclusive owner if the current exclusive thread is done
         if(threadMode!=2)
         {
             if(file->exclusiveRecurseCount==0)
                 clearThread(file->exclusiveOwner);
             pthread_cond_broadcast(&file->exclusiveChangeCondition);
         }
     }
     else
     {
         //if switching into exclusive mode, the current owner becomes the thread that did the switching by default
         if(threadMode==2)
             file->setExclusiveOwner(pthread_self(),0);
         file->currentThreadMode = threadMode;
     }
 }
Esempio n. 4
0
void M2File::waitExclusiveThread(size_t recurseCounter)
{
    //acquire a lock on the thread map
    m_MapMutex.lock();
    while(1)
    {
        //recursive mutex part -- if the current owner is self, return.
        //Note that there is always a current owner in exclusive mode so this works
        if(exclusiveOwner==pthread_self())
        {
            exclusiveRecurseCount+=recurseCounter;
            if(exclusiveRecurseCount==0)
            {
                pthread_cond_broadcast(&exclusiveChangeCondition);
                //this is to cover the case where we switch from 2 to 1 and need to set no exclusive owner upon exclusive finish
                if(currentThreadMode!=2)
                {
                    clearThread(exclusiveOwner);
                }
            }
            m_MapMutex.unlock();
            return;
        }
        //this handles the case where the user shifts from exclusive to synchronized mode
        if(currentThreadMode!=2)
        {
            if(currentThreadMode==1)
            {
                m_MapMutex.unlock();
                return;
            }
            return;
        }
        //otherwise wait for the exclusive thread to be changed
        pthread_cond_wait(&exclusiveChangeCondition,&m_MapMutex.m_Mutex);
    }
    m_MapMutex.unlock();
}
Esempio n. 5
0
M2File::M2File(stdio0_fileOutputSyncState fileUnsyncState):
    currentThreadMode(0),unsyncState(fileUnsyncState),recurseCount(0),exclusiveRecurseCount(0)
{
    clearThread(exclusiveOwner);
}