当前位置: 首页>>代码示例>>C++>>正文


C++ TestDestroy函数代码示例

本文整理汇总了C++中TestDestroy函数的典型用法代码示例。如果您正苦于以下问题:C++ TestDestroy函数的具体用法?C++ TestDestroy怎么用?C++ TestDestroy使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TestDestroy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fprintf

// 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
}
开发者ID:hihihippp,项目名称:kiku,代码行数:61,代码来源:web.cpp

示例2: while

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;
}
开发者ID:Strykar,项目名称:munin-node-win32,代码行数:30,代码来源:SpeedFanNodePlugin.cpp

示例3: while

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();
}
开发者ID:stahta01,项目名称:EmBlocks,代码行数:30,代码来源:FileExplorerUpdater.cpp

示例4: wxLogMessage

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;
}
开发者ID:N2maniac,项目名称:springlobby-join-fork,代码行数:33,代码来源:thread.cpp

示例5: locker

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;
}
开发者ID:DowerChest,项目名称:codeblocks,代码行数:60,代码来源:systemheadersthread.cpp

示例6: while

 virtual void *Entry() {
   while (!TestDestroy()) {
     m_Manager->TestPlugins();
     for (int i = 0; i < 50 && !TestDestroy(); i++)
       Sleep(100);
   }
   return NULL;
 };
开发者ID:Elbandi,项目名称:munin-node-win32,代码行数:8,代码来源:MuninPluginManager.cpp

示例7: GetTuneInUrl

// -------------------------------------------------------------------------------- //
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;
}
开发者ID:anonbeat,项目名称:guayadeque,代码行数:57,代码来源:TuneInRadio.cpp

示例8: WriteText

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;

}
开发者ID:mentat,项目名称:tehDJ,代码行数:54,代码来源:djThread.cpp

示例9: Entry

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 );
}
开发者ID:stahta01,项目名称:wxCode_components,代码行数:35,代码来源:MinimalServiceThread.cpp

示例10: wxLogMessage

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;
}
开发者ID:ruifig,项目名称:nutcracker,代码行数:60,代码来源:thread.cpp

示例11: Entry

	/*****************************************************
	**
	**   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;
	}
开发者ID:akshaykinhikar,项目名称:maitreya7,代码行数:32,代码来源:AtlasImporter.cpp

示例12: while

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;
}
开发者ID:BackupTheBerlios,项目名称:codelite-svn,代码行数:25,代码来源:worker_thread.cpp

示例13: Entry

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;
}
开发者ID:tmwatchanan,项目名称:ZipPicViewWx,代码行数:28,代码来源:ThumbnailLoadThread.cpp

示例14: while

// 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;
}
开发者ID:andybarry,项目名称:makerscanner,代码行数:34,代码来源:CaptureThread.cpp

示例15: Entry

 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;
 }
开发者ID:eranif,项目名称:codelite,代码行数:35,代码来源:clSSHChannel.cpp


注:本文中的TestDestroy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。