Пример #1
0
// thread
Web::ExitCode Web::Entry()
{
	#ifdef DEBUG
		fprintf(stdout, "Start Web\n");
	#endif

	wxHTTP get;
	get.SetHeader(_T("Content-type"), _T("text/html; charset=utf-8"));
	get.SetTimeout(30); 
	
	while (!get.Connect(_T("www.workinprogress.ca"))) {
		if(TestDestroy()) {
			return (wxThread::ExitCode)0;
		} else {
			wxSleep(5);
		}
	}
		
	wxInputStream *in_stream = get.GetInputStream(whaturl);
	
	if (get.GetError() == wxPROTO_NOERR)
	{
		bool shutdownRequest = false;
		unsigned char buffer[DLBUFSIZE+1];
		do {
			Sleep(0); //http://trac.wxwidgets.org/ticket/10720
			in_stream->Read(buffer, DLBUFSIZE);
			size_t bytes_read = in_stream->LastRead();
			if (bytes_read > 0) {

				buffer[bytes_read] = 0;
				wxString buffRead((const char*)buffer, wxConvUTF8);
				m_dataRead.Append(buffRead);
			}

			// Check termination request from time to time
			if(TestDestroy()) {
				shutdownRequest = true;
				break;
			}

		} while ( !in_stream->Eof() );
		
		wxDELETE(in_stream);
		get.Close();

		if(shutdownRequest == false) {
			delete in_stream;
			ParseFile(whaturl);
		}
		
	} else {
		return (wxThread::ExitCode)0;
	}
	#ifdef DEBUG
		fprintf(stdout, "Done Web\n");	
	#endif
	
	return (wxThread::ExitCode)0; // success
}
void *SpeedFanNodePlugin::ListenerThread::Entry()
{
  if (!OpenSocket()) {
    // Failed to open socket
    return NULL;
  }

  // Use a 2048 byte buffer, Ethernet frame size is 1500
  const int bufferSize = 2048;
  char *buffer = new char[bufferSize];
  while (!TestDestroy()) {
    // Reset the socket after recieving a packet
    int ret = m_Socket.RecvFrom(buffer, bufferSize);
    if (ret > 0) {
      buffer[ret] = 0;
      ProcessBuffer(buffer);
    } else {
      // Reopen socket
      if (TestDestroy() || !OpenSocket()) {
        // We need to exit or we failed to re-open the socket
        break;
      }
    }
    Sleep(0);
  }

  delete [] buffer;

  return NULL;
}
Пример #3
0
bool FileExplorerUpdater::CalcChanges()
{
    m_adders.clear();
    m_removers.clear();
    FileDataVec::iterator tree_it=m_treestate.begin();
    while(tree_it!=m_treestate.end() && !TestDestroy())
    {
        bool match=false;
        for(FileDataVec::iterator it=m_currentstate.begin();it!=m_currentstate.end();it++)
            if(it->name==tree_it->name)
            {
                match=true;
                if(it->state!=tree_it->state)
                {
                    m_adders.push_back(*it);
                    m_removers.push_back(*tree_it);
                }
                m_currentstate.erase(it);
                tree_it=m_treestate.erase(tree_it);
                break;
            }
        if(!match)
            tree_it++;
    }
    for(FileDataVec::iterator tree_it=m_treestate.begin();tree_it!=m_treestate.end();tree_it++)
        m_removers.push_back(*tree_it);
    for(FileDataVec::iterator it=m_currentstate.begin();it!=m_currentstate.end();it++)
        m_adders.push_back(*it);
    return !TestDestroy();
}
Пример #4
0
void* WorkerThread::Entry()
{
	WorkItem* item;

	wxLogMessage( _T( "WorkerThread started" ) );

	while ( !TestDestroy() ) {
		// sleep an hour or until a new WorkItem arrives (DoWork() will wake us up).
		Sleep( 3600 * 1000 );
		while ( !TestDestroy() && ( item = m_workItems.Pop() ) != NULL ) {
			try {
				wxLogMessage( _T( "running WorkItem %p, prio = %d" ), item, item->m_priority );
				item->Run();
			}
			catch ( ... ) {
				// better eat all exceptions thrown by WorkItem::Run(),
				// don't want to let the thread die on a single faulty WorkItem.
				wxLogMessage( _T( "WorkerThread caught exception thrown by WorkItem::Run" ) );
			}
			CleanupWorkItem( item );
			// give other threads some air
			Yield();
		}
	}

	// cleanup leftover WorkItems
	while ( ( item = m_workItems.Pop() ) != NULL ) {
		CleanupWorkItem( item );
	}

	wxLogMessage( _T( "WorkerThread stopped" ) );
	return 0;
}
Пример #5
0
void* SystemHeadersThread::Entry()
{
    wxArrayString dirs;
    {
        wxCriticalSectionLocker locker(*m_SystemHeadersThreadCS);
        for (size_t i=0; i<m_IncludeDirs.GetCount(); ++i)
        {
            if (m_SystemHeadersMap.find(m_IncludeDirs[i]) == m_SystemHeadersMap.end())
            {
                dirs.Add(m_IncludeDirs[i]);
                m_SystemHeadersMap[m_IncludeDirs[i]] = StringSet();
            }
        }
    }
    // collect header files in each dir, this is done by HeaderDirTraverser
    for (size_t i=0; i<dirs.GetCount(); ++i)
    {
        if ( TestDestroy() )
            break;

        // check the dir is ready for traversing
        wxDir dir(dirs[i]);
        if ( !dir.IsOpened() )
        {
            CodeBlocksThreadEvent evt(wxEVT_COMMAND_MENU_SELECTED, idSystemHeadersThreadError);
            evt.SetClientData(this);
            evt.SetString(wxString::Format(_T("SystemHeadersThread: Unable to open: %s"), dirs[i].wx_str()));
            wxPostEvent(m_Parent, evt);
            continue;
        }

        TRACE(_T("SystemHeadersThread: Launching dir traverser for: %s"), dirs[i].wx_str());

        HeaderDirTraverser traverser(this, m_SystemHeadersThreadCS, m_SystemHeadersMap, dirs[i]);
        dir.Traverse(traverser, wxEmptyString, wxDIR_FILES | wxDIR_DIRS);

        TRACE(_T("SystemHeadersThread: Dir traverser finished for: %s"), dirs[i].wx_str());

        if ( TestDestroy() )
            break;

        CodeBlocksThreadEvent evt(wxEVT_COMMAND_MENU_SELECTED, idSystemHeadersThreadUpdate);
        evt.SetClientData(this);
        evt.SetString(wxString::Format(_T("SystemHeadersThread: %s , %lu"), dirs[i].wx_str(), static_cast<unsigned long>(m_SystemHeadersMap[dirs[i]].size())));
        wxPostEvent(m_Parent, evt);
    }

    if ( !TestDestroy() )
    {
        CodeBlocksThreadEvent evt(wxEVT_COMMAND_MENU_SELECTED, idSystemHeadersThreadFinish);
        evt.SetClientData(this);
        if (!dirs.IsEmpty())
            evt.SetString(wxString::Format(_T("SystemHeadersThread: Total number of paths: %lu"), static_cast<unsigned long>(dirs.GetCount())));
        wxPostEvent(m_Parent, evt);
    }

    TRACE(_T("SystemHeadersThread: Done."));

    return NULL;
}
 virtual void *Entry() {
   while (!TestDestroy()) {
     m_Manager->TestPlugins();
     for (int i = 0; i < 50 && !TestDestroy(); i++)
       Sleep(100);
   }
   return NULL;
 };
Пример #7
0
// -------------------------------------------------------------------------------- //
int guTuneInReadStationsThread::AddStations( const wxString &url, guRadioStations * stations, const long minbitrate )
{
    wxString Content = GetTuneInUrl( url );
    //guLogMessage( wxT( "AddStations: %s" ), url.c_str() );

    if( !Content.IsEmpty() )
    {
        wxStringInputStream Ins( Content );
        wxXmlDocument XmlDoc( Ins );
        wxXmlNode * XmlNode = XmlDoc.GetRoot();
        if( XmlNode )
        {
            if( XmlNode->GetName() == wxT( "opml" ) )
            {
                XmlNode = XmlNode->GetChildren();
                while( XmlNode && !TestDestroy() )
                {
                    //guLogMessage( wxT( "XmlNode: '%s'" ), XmlNode->GetName().c_str() );
                    if( XmlNode->GetName() == wxT( "outline" ) )
                    {
                        wxString Type;
                        XmlNode->GetAttribute( wxT( "type" ), &Type );
                        if( Type == wxT( "" ) )
                        {
                            ReadStations( XmlNode->GetChildren(), stations, minbitrate );
                        }
                        else
                        {
                            ReadStations( XmlNode, stations, minbitrate );
                            break;
                        }
                    }
                    else if( XmlNode->GetName() == wxT( "body" ) )
                    {
                        XmlNode = XmlNode->GetChildren();
                        continue;
                    }

                    XmlNode = XmlNode->GetNext();
                }
            }
        }
    }

    if( !TestDestroy() )
    {
        SortStations();

        wxCommandEvent Event( wxEVT_MENU, ID_RADIO_UPDATED );
        wxPostEvent( m_RadioPanel, Event );

        return stations->Count();
    }

    return 0;
}
Пример #8
0
void *ProducerThread::Entry()
{
    WriteText("Producer started...");
    wxString info;

    unsigned long actual;

    while(true)
    {
        if (TestDestroy())
            break;

        if (mSeek)
        {
            WriteText("seeking");
            mCodec->Seek(mNewNumer, mNewDenom);
            mSeek = false;
        }

        if (mCodec->Ok())
        {
            actual = mSize;

            if (mCodec->GetPCMBlock(mPcm, &actual)) // get block from decoder
            {
                if (m_frame->m_visual)
                    m_frame->m_visual->Eat((short *)mPcm, actual, 16, 2);
                 // wait on queue
                while (!mOut->mQueue->push(mPcm, actual))
                {
                    if (TestDestroy())
                        return NULL;

                }
            }
            else
            {
                wxLogDebug("Songdone.");
                if (TestDestroy())
                    break;

                wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, ID_STOP);
                wxPostEvent( m_frame, event );

            }
        }
        else
            wxThread::Sleep(400);
    }

    
    return NULL;

}
MinimalServiceThread :: ExitCode  MinimalServiceThread :: Entry ()
{  
   // This will create a <name>.log file in the Windows SYSTEM32 directory!
   // Only create a <name>.log file when running as a service!

   FILE *         fp    = ( log == Log_FILE ) ? fopen ( name + ".log", "a" ) : 0;
   
// if ( fp == 0 )
//    return (  0 );
      
   wxLogStderr *  log   = new  wxLogStderr   ( fp );
   wxLog *        prev  = wxLog :: SetActiveTarget ( log );
   
   wxLogMessage ( "Minimal Started" );
   
   wxUint32    loop  = 0;
   
   while ( ! TestDestroy () )
   {
      wxLogMessage ( "Minimal Thread Loop %lu", ++loop );
      
      Sleep ( CYCLE_SLEEP );
   }
   
   wxLogMessage ( "Minimal Stopped" );

   wxLog :: SetActiveTarget ( prev );
   
   delete  log;

   if ( fp != 0 )   
      fclose ( fp );

   return (  0 );
}
Пример #10
0
wxThread::ExitCode MyGUIThread::Entry()
{
    // uncomment this to check that disabling logging here does disable it for
    // this thread -- but not the main one if you also comment out wxLogNull
    // line in MyFrame::OnStartGUIThread()
    //wxLogNull noLog;

    // this goes to the main window
    wxLogMessage("GUI thread starting");

    // use a thread-specific log target for this thread to show that its
    // messages don't appear in the main window while it runs
    wxLogBuffer logBuf;
    wxLog::SetThreadActiveTarget(&logBuf);

    for (int i=0; i<GUITHREAD_NUM_UPDATES && !TestDestroy(); i++)
    {
        // inform the GUI toolkit that we're going to use GUI functions
        // from a secondary thread:
        wxMutexGuiEnter();

        {
            wxCriticalSectionLocker lock(m_dlg->m_csBmp);

            // draw some more stuff on the bitmap
            wxMemoryDC dc(m_dlg->m_bmp);
            dc.SetBrush((i%2)==0 ? *wxBLUE_BRUSH : *wxGREEN_BRUSH);
            dc.DrawRectangle(rand()%GUITHREAD_BMP_SIZE, rand()%GUITHREAD_BMP_SIZE, 30, 30);

            // simulate long drawing time:
            wxMilliSleep(200);
        }

        // if we don't release the GUI mutex the MyImageDialog won't be able to refresh
        wxMutexGuiLeave();

        // notify the dialog that another piece of our masterpiece is complete:
        wxThreadEvent event( wxEVT_THREAD, GUITHREAD_EVENT );
        event.SetInt(i+1);
        wxQueueEvent( m_dlg, event.Clone() );

        if ( !((i + 1) % 10) )
        {
            // this message will go to the buffer
            wxLogMessage("Step #%d.", i + 1);
        }

        // give the main thread the time to refresh before we lock the GUI mutex again
        // FIXME: find a better way to do this!
        wxMilliSleep(100);
    }

    // now remove the thread-specific thread target
    wxLog::SetThreadActiveTarget(NULL);

    // so that this goes to the main window again
    wxLogMessage("GUI thread finished.");

    return (ExitCode)0;
}
Пример #11
0
wxThread::ExitCode MyThread::Entry()
{
    wxLogMessage("Thread started (priority = %u).", GetPriority());

    for ( m_count = 0; m_count < 10; m_count++ )
    {
        // check if the application is shutting down: in this case all threads
        // should stop a.s.a.p.
        {
            wxCriticalSectionLocker locker(wxGetApp().m_critsect);
            if ( wxGetApp().m_shuttingDown )
                return NULL;
        }

        // check if just this thread was asked to exit
        if ( TestDestroy() )
            break;

        wxLogMessage("Thread progress: %u", m_count);

        // wxSleep() can't be called from non-GUI thread!
        wxThread::Sleep(1000);
    }

    wxLogMessage("Thread finished.");

    return NULL;
}
Пример #12
0
	/*****************************************************
	**
	**   AtlasImportWorker   ---   Entry
	**
	******************************************************/
	ExitCode Entry()
	{
		sharedSection->threadStatus = THREADSTATUS_WAITING;

		while ( sharedSection->threadOrder != THREADORDER_EXIT )
		{
			Sleep( IMPORT_THREAD_SLEEP_MILLISEC );
			if ( sharedSection->threadOrder == THREADORDER_WORK )
			{
				TestDestroy();
				sharedSection->progress = 0;
				sharedSection->threadOrder = THREADORDER_NONE;
				sharedSection->threadStatus = THREADSTATUS_WORKING;
				sharedSection->errorCount = 0;
				totalsize = wxFileName::GetSize( sharedSection->sqlfile ).ToULong();
				doit();

				// set status to finished if not canceled or error
				if (  sharedSection->threadStatus == THREADSTATUS_WORKING )
				{
					sharedSection->threadStatus = THREADSTATUS_FINISHED;
				}
				sharedSection->hasNews = true;
			}
		}
		return 0;
	}
void* WorkerThread::Entry()
{
	while( true )
	{
		// Did we get a request to terminate?
		if(TestDestroy())
			break;

		ThreadRequest *request = GetRequest();
		if( request )
		{
			// Call user's implementation for processing request
			ProcessRequest( request );

			wxThread::Sleep(10);  // Allow other threads to work as well
			delete request;
			request = NULL;
			continue; // to avoid the sleep
		}

		// Sleep for 1 seconds, and then try again
		wxThread::Sleep(200);
	}
	return NULL;
}
wxThread::ExitCode ThumbnailLoadThread::Entry() {
  for (auto i = 0; i < entries.size(); ++i) {
    if (TestDestroy())
      break;

    auto entry = entries[i];
    auto image = entry->LoadImage();

    auto longerSide = image.GetWidth() > image.GetHeight() ? image.GetWidth()
                                                           : image.GetHeight();
    auto width = 200 * image.GetWidth() / longerSide;
    auto height = 200 * image.GetHeight() / longerSide;
    auto thumbnailImage = image.Scale(width, height, wxIMAGE_QUALITY_HIGH);

    auto event = new wxThreadEvent(wxEVT_COMMAND_THMBTREAD_UPDATE);

    ThumbnailData data;
    data.index = i;
    data.image = thumbnailImage;
    data.total = entries.size();
    event->SetPayload(data);

    wxQueueEvent(m_pHandler, event);
  }

  wxQueueEvent(m_pHandler, new wxThreadEvent(wxEVT_COMMAND_THMBTREAD_DONE));
  return (wxThread::ExitCode)0;
}
Пример #15
0
// Called when thread is started
void* CaptureThread::Entry()
{
    while (true)
    {
        // check to see if the thread should exit
        if (TestDestroy() == true)
        {
            break;
        }

        if (capturing == CAPTURE)
        {
            // get a new image
            CaptureFrame();
        } else if (capturing == PREVIEW)
        {

            // get a new image and show it on screen
            CaptureFrame();
            SendFrame(imageQueue.back());
        } else if (capturing == IDLE)
        {
            Sleep(10);
        } else if (capturing == STOP)
        {
            break;
        }

        Yield();
    }

    return NULL;
}
Пример #16
0
 void* Entry()
 {
     while(!TestDestroy()) {
         // First, poll the channel
         int bytes = ssh_channel_poll_timeout(m_channel, 500, 0);
         if(bytes == SSH_ERROR) {
             // an error
             clCommandEvent event(wxEVT_SSH_CHANNEL_READ_ERROR);
             m_handler->AddPendingEvent(event);
             break;
         } else if(bytes == SSH_EOF) {
             clCommandEvent event(wxEVT_SSH_CHANNEL_CLOSED);
             m_handler->AddPendingEvent(event);
             break;
         } else if(bytes == 0) {
             continue;
         } else {
             // there is something to read
             char* buffer = new char[bytes + 1];
             if(ssh_channel_read(m_channel, buffer, bytes, 0) != bytes) {
                 clCommandEvent event(wxEVT_SSH_CHANNEL_READ_ERROR);
                 m_handler->AddPendingEvent(event);
                 wxDELETEA(buffer);
                 break;
             } else {
                 buffer[bytes] = 0;
                 clCommandEvent event(wxEVT_SSH_CHANNEL_READ_OUTPUT);
                 event.SetString(wxString(buffer, wxConvUTF8));
                 m_handler->AddPendingEvent(event);
                 wxDELETEA(buffer);
             }
         }
     }
     return NULL;
 }
Пример #17
0
wxThread::ExitCode MyThread::Entry() {

    while (Check()) {
        {
            wxCriticalSectionLocker locker(wxGetApp().myapp_critsect);

            // If stop button pressed then return immediately
            if ( wxGetApp().myapp_shut_down ) {
                return NULL;
            }
        }
        // check if just this thread was asked to exit
        if ( TestDestroy() )
            break;

        wxString login = Read();

        //mt_curl->SetLogin(login.BeforeFirst('@'));
        mt_curl->SetLogin(login);

        if (mt_curl->IsAvailable()) {
            wxCriticalSectionLocker lock(mt_critsect);
            num_good++;
            file_good.AddLine(login);
            file_good.Write();
            notif_str += login;
            notif_str += '\n';
        }
        else {
            wxCriticalSectionLocker lock(mt_critsect);
            num_bad++;
        }
    }
    return NULL;
}
Пример #18
0
void *wxSizeCacherThread::Entry()
{
    wxLogAdvMsg(wxT("wxSizeCacherThread::Entry - caching file sizes"));
    bool allok = TRUE;

    if (m_urls.GetCount() == 0)
        return (void*)FALSE;     // no urls whose size must be cached ?

    // be sure to have n null entries in our cache array, where
    // 'n' is the number of URLs whose size must be cached
    m_urlSizes = new wxArrayLong();
    m_urlSizes->Add((long)0, m_urls.GetCount());

    // begin our loop
    for (int i=0; i<(int)m_urls.GetCount() && !TestDestroy(); i++) {

        // getting the input stream for the url is the only way
        // to get the size of the resource pointed by that url...
        m_urlSizes->Item(i) = wxGetSizeOfURI(m_urls[i]);
        allok &= (m_urlSizes->Item(i) != 0);
    }

    wxLogAdvMsg(wxT("wxSizeCacherThread::Entry - caching of file sizes completed"));
    return (void *)allok;
}
Пример #19
0
wxThread::ExitCode MyDetachedThread::Entry()
{
    {
        wxCriticalSectionLocker lock(gs_critsect);
        if ( gs_counter == (size_t)-1 )
            gs_counter = 1;
        else
            gs_counter++;
    }

    for ( size_t n = 0; n < m_n; n++ )
    {
        if ( TestDestroy() )
        {
            m_cancelled = true;

            break;
        }

        //wxPutchar(m_ch);
        //fflush(stdout);

        wxMilliSleep(100);
    }

    return 0;
}
Пример #20
0
void InterpreterDisAsmFrame::Task()
{
	if(!CPU) return;
	wxGetApp().SendDbgCommand(DID_RESUME_THREAD, CPU);
	wxGetApp().SendDbgCommand(DID_RESUMED_THREAD, CPU);
	bool dump_status = dump_enable;

	//CPU.InitTls();

	try
	{
		do
		{
			CPU->ExecOnce();
		}
		while(CPU->IsRunning() && Emu.IsRunning() && !TestDestroy() && !IsBreakPoint(CPU->PC) && dump_status == dump_enable);
	}
	catch(const wxString& e)
	{
		ConLog.Error(e);
	}
	catch(...)
	{
		ConLog.Error("Unhandled exception.");
	}

	//CPU.FreeTls();

	wxGetApp().SendDbgCommand(DID_PAUSE_THREAD, CPU);
	wxGetApp().SendDbgCommand(DID_PAUSED_THREAD, CPU);
}
Пример #21
0
void LogFrame::Task()
{
	while(!TestDestroy())
	{
		if(!LogBuffer.HasNewPacket())
		{
			Sleep(1);
			continue;
		}
		else
		{
			wxThread::Yield();
		}

		const LogPacket item = LogBuffer.Pop();

		while(m_log.GetItemCount() > max_item_count)
		{
			m_log.DeleteItem(0);
			wxThread::Yield();
		}

		const int cur_item = m_log.GetItemCount();

		m_log.InsertItem(cur_item, item.m_prefix);
		m_log.SetItem(cur_item, 1, item.m_text);
		m_log.SetItemTextColour(cur_item, item.m_colour);
		m_log.SetColumnWidth(0, -1);
		m_log.SetColumnWidth(1, -1);

		::SendMessage((HWND)m_log.GetHWND(), WM_VSCROLL, SB_BOTTOM, 0);
	}

	LogBuffer.Flush();
}
Пример #22
0
// -------------------------------------------------------------------------------- //
guTuneInReadStationsThread::~guTuneInReadStationsThread()
{
    if( !TestDestroy() )
    {
        m_TuneInProvider->EndReadStationsThread();
    }
}
Пример #23
0
void* FindInProjectDlg::SearchThread::Entry() {
    while (1) {
        // Wait for signal that we should start search
        m_isWaiting = true;
        wxMutexLocker lock(m_condMutex);
        m_startSearchCond.Wait();
        m_isWaiting = false;

        if (m_stopSearch) {
            while (1) {
                if (TestDestroy()) break;
                Sleep(100);
            }
        }

        m_isSearching = true;

        SearchInfo si;
        PrepareSearchInfo(si, m_pattern, m_matchCase);

        ProjectInfoHandler infoHandler;
        infoHandler.SetRoot(m_path);

        // Write the html header for output
        m_outputCrit.Enter();
        m_output = wxT("<head><style type=\"text/css\">#match {background-color: yellow}</style></head>");
        m_outputCrit.Leave();

        SearchDir(m_path, si, infoHandler);
        m_isSearching = false;
    }

    return NULL;
}
Пример #24
0
bool ListMarketBook::DoListMarketBook() {

    std::vector<std::string> marketIds;
    marketIds.push_back(market.GetMarketCatalogue().getMarketId());
    std::set<greentop::PriceData> priceData;
    priceData.insert(greentop::PriceData(greentop::PriceData::EX_BEST_OFFERS));
    greentop::PriceProjection priceProjection(priceData);
    // show "virtual" bets
    priceProjection.setVirtualise(true);
    greentop::OrderProjection orderProjection(greentop::OrderProjection::EXECUTABLE);
    greentop::MatchProjection matchProjection(greentop::MatchProjection::ROLLED_UP_BY_AVG_PRICE);
    greentop::ListMarketBookRequest listMarketBookRequest(marketIds, priceProjection, orderProjection, matchProjection);

    greentop::ListMarketBookResponse lmbResp = GreenThumb::GetBetfairApi().listMarketBook(listMarketBookRequest);

    if (TestDestroy()) {
        return false;
    }

    if (lmbResp.isSuccess()) {
        for (unsigned i = 0; i < lmbResp.getMarketBooks().size(); ++i) {
            betfairMarketBook = lmbResp.getMarketBooks()[i];
            break;
        }
        return true;
    }
    return false;
}
Пример #25
0
void *deviceReceiveThread::Entry()
{
    // Must be a valid main object pointer
    if ( NULL == m_pMainThreadObj ) return NULL;

    wxCommandEvent eventReceive( wxVSCP_IN_EVENT, m_pMainThreadObj->m_pCtrlObject->m_windowID );
    canalMsg msg;

    // Blocking receive method must have been found
    if ( NULL == m_pMainThreadObj->m_pCtrlObject->m_proc_CanalBlockingReceive ) return NULL;

    while ( !TestDestroy() && !m_bQuit )
    {

        if ( CANAL_ERROR_SUCCESS == m_pMainThreadObj->m_pCtrlObject->m_proc_CanalBlockingReceive( m_pMainThreadObj->m_pCtrlObject->m_openHandle, &msg, 500 ) )
        {

            vscpEvent *pEvent = new vscpEvent;
            if ( NULL != pEvent ) {

                // Convert CANAL message to VSCP event
                convertCanalToEvent ( pEvent,
                                        &msg,
                                        m_pMainThreadObj->m_pCtrlObject->m_GUID );

                eventReceive.SetClientData( pEvent );
                wxPostEvent( m_pMainThreadObj->m_pCtrlObject->m_pWnd, eventReceive );

            }
        }
    }

    return NULL;

}
Пример #26
0
void* JobPoolWorker::Entry()
{
#ifdef LINUX
    XInitThreads();
#endif
    while ( !stopped ) {
        // Did we get a request to terminate?
        if (TestDestroy())
            break;

        Job *job = GetJob();
        if (job) {
            // Call user's implementation for processing request
            ProcessJob(job);
            if (job->DeleteWhenComplete()) {
                delete job;
            }
            job = NULL;
        } else {
            std::unique_lock<std::mutex> mutLock(*lock);
            if (idleThreads > 5) {
                break;
            }
        }
    }
    std::unique_lock<std::mutex> mutLock(*lock);
    numThreads--;
    return NULL;
}
Пример #27
0
void DbgConsole::Task()
{
	while(!TestDestroy())
	{
		if(!m_dbg_buffer.HasNewPacket())
		{
			if (Emu.IsStopped())
			{
				break;
			}
			Sleep(1);
			continue;
		}

		DbgPacket packet = m_dbg_buffer.Pop();
		m_console->SetDefaultStyle(packet.m_ch == 1 ? *m_color_red : *m_color_white);
		m_console->SetInsertionPointEnd();
		m_console->WriteText(packet.m_text);

		if (m_output && Ini.HLESaveTTY.GetValue())
			m_output->Write(packet.m_text);

		if(!DbgConsole::IsShown()) Show();
	}
}
Пример #28
0
void* JobPoolWorker::Entry()
{
#ifdef LINUX
    XInitThreads();
#endif
    while ( true ) {
        // Did we get a request to terminate?
        if (TestDestroy())
            break;

        Job *job = GetJob();
        if (job) {
            // Call user's implementation for processing request
            ProcessJob(job);
            delete job;
            job = NULL;
        } else {
            wxMutexLocker mutLock(*lock);
            if (idleThreads > 5) {
                break;
            }
        }
    }
    wxMutexLocker mutLock(*lock);
    numThreads--;
    return NULL;
}
Пример #29
0
wxThread::ExitCode MyWorkerThread::Entry() {

	// check if the application is shutting down:
	// in this case thread should stop a.s.a.p.
	{
		wxCriticalSectionLocker locker(wxGetApp().m_critsect);
		if ( wxGetApp().m_shuttingDown ) return NULL;
	}

	if (m_frame->Canceled()) return NULL;

	// check if we were asked to exit
	if (TestDestroy()) return NULL;

	if (!m_task->is_ready()) return NULL;

	m_task->set_running(true);

	emit_event(m_status);

	// task->execute() runs a shell to call xperimenter.R which processes the
	// params.csv file and, in turn, runs another shell to call the actual task
	// program with the parameters input by the user.
	bp::child c = m_task->execute();
	m_task->set_process(&c);
	bp::posix_status s = c.wait();
	//auto exitStatus = bp::wait_for_exit(c);
	//int exitCode = BOOST_PROCESS_EXITSTATUS(exitStatus);
	//int* status = &exitCode;
	//m_status = *((int*)status);
	m_status = s.exit_status();

	return &m_status;
}
void *	wxServiceDiscoveryTaskBase::wxServiceDiscoveryServiceHelperThread::Entry()
{
		//	static wxCriticalSection section;
		//	wxCriticalSectionLocker section_locker( section );
		
		wxASSERT( ! wxThread::IsMain() );
		
		bool cancel_running = false;
		DNSServiceErrorType err = kDNSServiceErr_NoError; 
		
		do
		{
			err = DNSServiceProcessResult( m_ServiceRef );
			
			if ( err )
			{
				if ( err == kDNSServiceErr_Unknown )
				{
					wxLogDebug( wxT("Received an unknown bonjour error, but this was probably just a method of quitting our thread.") );
				}
				else
				{
					wxLogDebug( wxT("got error!  %d"),
								err );
				}
				cancel_running = true;
			}
			
		} while ( ! TestDestroy() && !cancel_running );
		
		return NULL;
}