Exemplo n.º 1
0
void CBackgroundInfoLoader::Load(CFileItemList& items)
{
  StopThread();

  if (items.Size() == 0)
    return;

  CSingleLock lock(m_lock);

  for (int nItem=0; nItem < items.Size(); nItem++)
    m_vecItems.push_back(items[nItem]);

  m_pVecItems = &items;
  m_bStop = false;
  m_bStartCalled = false;

  int nThreads = m_nRequestedThreads;
  if (nThreads == -1)
    nThreads = (m_vecItems.size() / (ITEMS_PER_THREAD+1)) + 1;

  if (nThreads > g_advancedSettings.m_bgInfoLoaderMaxThreads)
    nThreads = g_advancedSettings.m_bgInfoLoaderMaxThreads;

  m_nActiveThreads = nThreads;
  for (int i=0; i < nThreads; i++)
  {
    CThread *pThread = new CThread(this, "Background Loader");
    pThread->Create();
#ifndef _LINUX
    pThread->SetPriority(THREAD_PRIORITY_BELOW_NORMAL);
#endif
    m_workers.push_back(pThread);
  }

}
Exemplo n.º 2
0
 CNetTest():m_clsEpoll(255)
 {
     serv.Create(this,&self_t::Server);
     listener.Listen(8899);
     m_clsEpoll.Add(listener.m_iSock,EPOLLIN|EPOLLET,(void*)&listener);
     m_clsEpoll.m_pNotify=this;
     //client.Create(this,&self_t::Server);
 }
Exemplo n.º 3
0
void CBackgroundInfoLoader::Load(CFileItemList& items)
{
  StopThread();

  if (items.Size() == 0)
    return;
  
  EnterCriticalSection(m_lock);

  for (int nItem=0; nItem < items.Size(); nItem++)
    m_vecItems.push_back(items[nItem]);

  m_pVecItems = &items;
  m_bStop = false;
  m_bStartCalled = false;

  int nThreads = m_nRequestedThreads;
  if (nThreads == -1)
    nThreads = (m_vecItems.size() / (ITEMS_PER_THREAD+1)) + 1;

  if (nThreads > g_advancedSettings.m_bgInfoLoaderMaxThreads)
    nThreads = g_advancedSettings.m_bgInfoLoaderMaxThreads;

  if (items.IsSmb() && nThreads > MAX_SMB_THREAD_COUNT)
    nThreads = MAX_SMB_THREAD_COUNT;

  m_nActiveThreads = nThreads;
  CLog::Log(LOGDEBUG,"CBackgroundInfoLoader::Load - creating %d threads",nThreads);
  for (int i=0; i < nThreads; i++)
  {
    CThread *pThread = new CThread(this); 
    pThread->SetName("Background Loader");
    m_workers.push_back(pThread);
    pThread->Create();
#ifndef _LINUX
    pThread->SetPriority(THREAD_PRIORITY_BELOW_NORMAL);
#endif
  }
      
  LeaveCriticalSection(m_lock);
}