• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ wxMutex类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ReadFromBuffer

void HexEditorCtrl::ReadFromBuffer( uint64_t position, unsigned lenght, char *buffer, bool cursor_reset, bool paint ){
	static wxMutex MyBufferMutex;
	MyBufferMutex.Lock();
	page_offset = position;
	if( lenght != ByteCapacity() ){
		//last line could be NULL;
		}
	Clear( false, cursor_reset );
	wxString text_string;
// Optimized Code
	for( unsigned i=0 ; i<lenght ; i++ )
		text_string << text_ctrl->Filter(buffer[i]);

	//Painting Zebra Stripes, -1 means no stripe. 0 means start with normal, 1 means start with zebra
	*ZebraStriping=(ZebraEnable ? position/BytePerLine()%2 : -1);
	if(sector_size > 1){
		offset_ctrl->sector_size=sector_size;
		int draw_line=sector_size-(page_offset%sector_size);
		hex_ctrl->ThinSeperationLines.Clear();
		text_ctrl->ThinSeperationLines.Clear();
			do{
			hex_ctrl->ThinSeperationLines.Add( 2*draw_line );
			text_ctrl->ThinSeperationLines.Add( draw_line );
			draw_line += sector_size;
			}while (draw_line < lenght );
		}

	hex_ctrl->SetBinValue(buffer, lenght, false );
	text_ctrl->ChangeValue(text_string, false);
	offset_ctrl->SetValue( position, BytePerLine() );

	if( offset_scroll->GetThumbPosition() not_eq (page_offset / BytePerLine()) )
		offset_scroll->SetThumbPosition( page_offset / BytePerLine() );

	if( paint ){
		PaintSelection();
		}
//	sector_size=128;
//	if(sector_size > 1){
//		int draw_line=sector_size-(page_offset%sector_size);
//			do{
//			hex_ctrl->DrawSeperationLineAfterChar( 2*draw_line );
//			text_ctrl->DrawSeperationLineAfterChar( draw_line );
//			draw_line += sector_size;
//			}while (draw_line < GetByteCount() );
//		}
	MyBufferMutex.Unlock();
	}
开发者ID:sustmi,项目名称:sus107-dt,代码行数:48,代码来源:HexEditorCtrl.cpp


示例2: ReadFromBuffer

//-----READ/WRITE FUNCTIONS-------//
void HexEditorCtrl::ReadFromBuffer( uint64_t position, unsigned lenght, char *buffer, bool cursor_reset, bool paint ){
	if( lenght==4294967295LL ){
		std::cout << "Buffer has no data!" << std::endl;
		return;
		}
	static wxMutex MyBufferMutex;
	MyBufferMutex.Lock();
	page_offset = position;
	if( lenght != ByteCapacity() ){
		//last line could be NULL;
		}
	Clear( false, cursor_reset );
	wxString text_string;

// Optimized Code
//	for( unsigned i=0 ; i<lenght ; i++ )
		//text_string << text_ctrl->Filter(buffer[i]);
//		text_string << static_cast<wxChar>((unsigned char)(buffer[i]));
//		text_string << CP473toUnicode((unsigned char)(buffer[i]));

	//Painting Zebra Stripes, -1 means no stripe. 0 means start with normal, 1 means start with zebra
	*ZebraStriping=(ZebraEnable ? position/BytePerLine()%2 : -1);
	if(sector_size > 1){
		offset_ctrl->sector_size=sector_size;
		unsigned draw_line=sector_size-(page_offset%sector_size);
		hex_ctrl->ThinSeparationLines.Clear();
		text_ctrl->ThinSeparationLines.Clear();
			do{
			hex_ctrl->ThinSeparationLines.Add( 2*draw_line );
			text_ctrl->ThinSeparationLines.Add( draw_line );
			draw_line += sector_size;
			}while (draw_line < lenght );
		}

	if(ProcessRAMMap.Count()){
		hex_ctrl->ThinSeparationLines.Clear();
		text_ctrl->ThinSeparationLines.Clear();
		//Notice that, ProcessRAMMap is SORTED.
		for( unsigned i=0; i < ProcessRAMMap.Count(); i++ ){
			int64_t M = ProcessRAMMap.Item(i);
			if( M > page_offset + ByteCapacity() )
				break;

			if(    (M > page_offset)
				&& (M <= page_offset + ByteCapacity()) ){

				int draw_line = M - page_offset;
				hex_ctrl->ThinSeparationLines.Add( 2*draw_line );
				text_ctrl->ThinSeparationLines.Add( draw_line );
				}
			}
		}

	hex_ctrl->SetBinValue(buffer, lenght, false );
	//text_ctrl->ChangeValue(text_string, false);
	text_ctrl->SetBinValue(buffer, lenght, false);

	offset_ctrl->SetValue( position, BytePerLine() );

	if( offset_scroll->GetThumbPosition() != (page_offset / BytePerLine()) )
		offset_scroll->SetThumbPosition( page_offset / BytePerLine() );

	if( paint ){
		PaintSelection();
		}

	MyBufferMutex.Unlock();
	}
开发者ID:ChunHungLiu,项目名称:wxHexEditor,代码行数:69,代码来源:HexEditorCtrl.cpp


示例3: while

void  layprop::ViewProperties::lockLayer(word layno, bool lock) {
   // No error messages here, because of possible range use
   while (wxMUTEX_NO_ERROR != DBLock.TryLock());
   if (_drawprop._layset.end() != _drawprop._layset.find(layno))
      _drawprop._layset[layno]->_locked = lock;
   DBLock.Unlock();
}
开发者ID:BackupTheBerlios,项目名称:toped-svn,代码行数:7,代码来源:viewprop.cpp


示例4: Entry

	/*****************************************************
	**
	**   AtlasLogicCountWorker   ---   Entry
	**
	******************************************************/
	ExitCode Entry()
	{
		while ( sharedSection->doExit == false )
		{
			Sleep( COUNT_THREAD_SLEEP_MILLISEC );
			if ( sharedSection->countHasOrder )
			{
#ifdef DEB_ATLAS_LOGIC
				printf( "AtlasLogicCountWorker: location count started, filter \"%s\", country \"%s\", mode %d\n",
					str2char( logic->filter ), str2char( logic->country ), logic->mode );
				wxLongLong starttime = wxGetLocalTimeMillis();
#endif
				sharedSection->countHasOrder = false;
				int c = dao->getMatchCount( logic->filter, logic->country, logic->mode );

				if ( sharedSection->countHasOrder )
				{
					// new order arrived, filter conditions have changed meanwhile: do not write results
					printf( "WARN: AtlasLogicCountWorker has new order before finishing request\n" );
				}
				else
				{
					mutex.Lock();
					sharedSection->countHasNews = true;
					sharedSection->count = c;
					mutex.Unlock();
#ifdef DEB_ATLAS_LOGIC
					wxLongLong duration = wxGetLocalTimeMillis() - starttime;
					printf( "AtlasLogicCountWorker: Location count finished, %d results in %ld millisec\n", c, duration.ToLong() );
#endif
				}
			}
		}
		return 0;
	}
开发者ID:akshaykinhikar,项目名称:maitreya7,代码行数:40,代码来源:AtlasLogic.cpp


示例5: Play

bool wxSoundSyncOnlyAdaptor::Play(wxSoundData *data, unsigned flags,
                                  volatile wxSoundPlaybackStatus *status)
{
    Stop();
    if (flags & wxSOUND_ASYNC)
    {
#if wxUSE_THREADS
        m_mutexRightToPlay.Lock();
        m_status.m_playing = true;
        m_status.m_stopRequested = false;
        data->IncRef();
        wxThread *th = new wxSoundAsyncPlaybackThread(this, data, flags);
        th->Create();
        th->Run();
        wxLogTrace(_T("sound"), _T("launched async playback thread"));
        return true;
#else
        wxLogError(_("Unable to play sound asynchronously."));
        return false;
#endif
    }
    else
    {
#if wxUSE_THREADS
        m_mutexRightToPlay.Lock();
#endif
        bool rv = m_backend->Play(data, flags, status);
#if wxUSE_THREADS
        m_mutexRightToPlay.Unlock();
#endif
        return rv;
    }
}
开发者ID:project-renard-survey,项目名称:chandler,代码行数:33,代码来源:sound.cpp


示例6: Max

/*****************************************************
**
**   AtlasLogic   ---   getEntryByRowId
**
******************************************************/
AtlasEntry *AtlasLogic::getEntryByRowId( const int &rowid )
{
	assert( sharedSection );

	mutex.Lock();
	for ( int i = 0; i < ATLAS_MAX_GRID_ELEMENTS; i++ )
	{
		if ( entries[i] != 0 && entries[i]->rowid == rowid )
		{
			mutex.Unlock();
			return entries[i];
		}
	}
	mutex.Unlock();

	if ( rowid > 0 && ! sharedSection->fetchHasOrder && ! sharedSection->fetchIsWorking )
	{
		mutex.Lock();
		resetEntries();
		sharedSection->fetchOffset = Max( 0, rowid - 15 );
		sharedSection->fetchHasOrder = true;
		mutex.Unlock();
	}
	return 0;
}
开发者ID:akshaykinhikar,项目名称:maitreya7,代码行数:30,代码来源:AtlasLogic.cpp


示例7: setDatabaseFile

void AtlasImporter::setDatabaseFile( wxString s )
{
	assert( sharedSection );
	mutex.Lock();
	sharedSection->dbfile = s;
	mutex.Unlock();
}
开发者ID:akshaykinhikar,项目名称:maitreya7,代码行数:7,代码来源:AtlasImporter.cpp


示例8: setImportFile

void AtlasImporter::setImportFile( wxString s )
{
	assert( sharedSection );
	mutex.Lock();
	sharedSection->sqlfile = s;
	mutex.Unlock();
}
开发者ID:akshaykinhikar,项目名称:maitreya7,代码行数:7,代码来源:AtlasImporter.cpp


示例9: updateFilter

/*****************************************************
**
**   AtlasLogic   ---   updateFilter
**
******************************************************/
void AtlasLogic::updateFilter()
{
	mutex.Lock();
	resetEntries();

	assert( sharedSection );
	sharedSection->countHasOrder = true;
	sharedSection->fetchHasOrder = true;
	mutex.Unlock();
}
开发者ID:akshaykinhikar,项目名称:maitreya7,代码行数:15,代码来源:AtlasLogic.cpp


示例10: openGL_draw

void DataCenter::openGL_draw(layprop::DrawProperties& drawprop) {
// Maybe we need another try/catch in the layoutcanvas ?   
   if (_TEDDB) {
//      _TEDDB->check_active();
      while (wxMUTEX_NO_ERROR != DBLock.TryLock());
      _TEDDB->openGL_draw(drawprop);
      DBLock.Unlock();
   }
// 
//   else throw EXPTNactive_DB();      
}
开发者ID:BackupTheBerlios,项目名称:toped-svn,代码行数:11,代码来源:datacenter.cpp


示例11: tmp_draw

void DataCenter::tmp_draw(const layprop::DrawProperties& drawprop,
                              TP base, TP newp) {
   if (_TEDDB) {
//      _TEDDB->check_active();
      while (wxMUTEX_NO_ERROR != DBLock.TryLock());
      _TEDDB->tmp_draw(drawprop, base, newp);
      DBLock.Unlock();
   }
// 
//   else throw EXPTNactive_DB();      
}
开发者ID:BackupTheBerlios,项目名称:toped-svn,代码行数:11,代码来源:datacenter.cpp


示例12: execQueryBundle

	/*****************************************************
	**
	**   AtlasImportWorker   ---   execQueryBundle
	**
	******************************************************/
	int execQueryBundle()
	{
		int ret = dao->executeQueryBundle( qb, false );
		if( ret != (int)qb.size())
		{
			mutex.Lock();
			sharedSection->errorCount++;
			sharedSection->errorMessage = dao->getLastErrorMessage();
			sharedSection->threadStatus = THREADSTATUS_ERROR;
			mutex.Unlock();
		}
		qb.clear();
		return ret;
	}
开发者ID:akshaykinhikar,项目名称:maitreya7,代码行数:19,代码来源:AtlasImporter.cpp


示例13: while

//==============================================================================
void* console::parse_thread::Entry() {
//   wxLogMessage(_T("Mouse is %s (%ld, %ld)"), where.c_str(), x, y);
//   wxLogMessage(_T("Mutex try to lock..."));
   while (wxMUTEX_NO_ERROR != Mutex.TryLock());
//   wxLogMessage(_T("Mutex locked!"));
   telllloc.first_column = telllloc.first_line = 1;
   telllloc.last_column  = telllloc.last_line  = 1;
   telllloc.filename = NULL;
   void* b = tell_scan_string( command.c_str() );
   tellparse();
   my_delete_yy_buffer( b );
   Mutex.Unlock();
//   wxLogMessage(_T("Mutex unlocked"));
   return NULL;
};
开发者ID:BackupTheBerlios,项目名称:toped-svn,代码行数:16,代码来源:ted_prompt.cpp


示例14: OnSelRightClick

////////////////////////////////////////////////////////////////////////////////
// This handler will display a popup menu for the item at the mouse position
////////////////////////////////////////////////////////////////////////////////
void frmMain::OnSelRightClick(wxTreeEvent &event)
{
	wxTreeItemId item = event.GetItem();
	if (item != browser->GetSelection())
	{
		browser->SelectItem(item);

		// Prevent changes to "currentObject" by "execSelchange" function by another
		// thread. Will hold the lock until we have the actual object in hand.
		s_currentObjectMutex.Lock();
		currentObject = browser->GetObject(item);
		s_currentObjectMutex.Unlock();
	}

	if (currentObject)
		doPopup(browser, event.GetPoint(), currentObject);
}
开发者ID:search5,项目名称:pgadmin3,代码行数:20,代码来源:events.cpp


示例15: Stop

void wxSoundSyncOnlyAdaptor::Stop()
{
    wxLogTrace(_T("sound"), _T("asking audio to stop"));

#if wxUSE_THREADS
    // tell the player thread (if running) to stop playback ASAP:
    m_status.m_stopRequested = true;

    // acquire the mutex to be sure no sound is being played, then
    // release it because we don't need it for anything (the effect of this
    // is that calling thread will wait until playback thread reacts to
    // our request to interrupt playback):
    m_mutexRightToPlay.Lock();
    m_mutexRightToPlay.Unlock();
    wxLogTrace(_T("sound"), _T("audio was stopped"));
#endif
}
开发者ID:project-renard-survey,项目名称:chandler,代码行数:17,代码来源:sound.cpp


示例16: lockDB

laydata::tdtdesign*  DataCenter::lockDB(bool checkACTcell) 
{
   if (_TEDDB) 
   {
      if (checkACTcell) _TEDDB->check_active();
      while (wxMUTEX_NO_ERROR != DBLock.TryLock());
      return _TEDDB;
   }
   else throw EXPTNactive_DB();
}
开发者ID:BackupTheBerlios,项目名称:toped-svn,代码行数:10,代码来源:datacenter.cpp


示例17: Entry

wxThread::ExitCode AegisubVersionCheckerThread::Entry()
{
	if (!interactive)
	{
		// Automatic checking enabled?
		if (!OPT_GET("App/Auto/Check For Updates")->GetBool())
			return 0;

		// Is it actually time for a check?
		time_t next_check = OPT_GET("Version/Next Check")->GetInt();
		if (next_check > wxDateTime::GetTimeNow())
			return 0;
	}

	if (VersionCheckLock.TryLock() != wxMUTEX_NO_ERROR) return 0;

	try {
		DoCheck();
	}
	catch (const agi::Exception &e) {
		PostErrorEvent(wxString::Format(
			_("There was an error checking for updates to Aegisub:\n%s\n\nIf other applications can access the Internet fine, this is probably a temporary server problem on our end."),
			e.GetMessage()));
	}
	catch (...) {
		PostErrorEvent(_("An unknown error occurred while checking for updates to Aegisub."));
	}

	VersionCheckLock.Unlock();

	// While Options isn't perfectly thread safe, this should still be okay.
	// Traversing the std::map to find the key-value pair doesn't modify any data as long as
	// the key already exists (which it does at this point), and modifying the value only
	// touches that specific key-value pair and will never cause a rebalancing of the tree,
	// because the tree only depends on the keys.
	// Lastly, writing options to disk only happens when Options.Save() is called.
	time_t new_next_check_time = wxDateTime::GetTimeNow() + 60*60; // in one hour
	OPT_SET("Version/Next Check")->SetInt((int)new_next_check_time);

	return 0;
}
开发者ID:Gpower2,项目名称:Aegisub,代码行数:41,代码来源:dialog_version_check.cpp


示例18: Entry

void* Thread_ChangedSince::Entry()
{

	wxString timeStamp = m_pKbSvr->GetKBServerLastSync();

	s_BulkDeleteMutex.Lock();

	int rv = m_pKbSvr->ChangedSince_Timed(timeStamp); // 2nd param, bDoTimestampUpdate is default TRUE

	s_BulkDeleteMutex.Unlock();

	// If rv = 0 (ie. no error) is returned, the server's downloaded timestamp will have
	// been used at the end of ChangedSince_Queued() to update the stored value at the
	// client end , so it doesn't need to be done here - but that's provided
	// bDoTimestampUpdate param takes the default TRUE value; if an explicit
	// FALSE were passed in, no timestamp update would be done
	if (rv != 0)
	{
		; // do nothing, error handling is at a lower level
	}
	return (void*)NULL;
}
开发者ID:eb1,项目名称:adaptit,代码行数:22,代码来源:Thread_ChangedSince.cpp


示例19: lockGDS

GDSin::GDSFile* DataCenter::lockGDS(bool throwexception) 
{
   // Carefull HERE! When GDS is locked form the main thread
   // (GDS browser), then there is no catch pending -i.e.
   // throwing an exception will make the things worse
   // When it is locked from the parser command - then exception
   // is fine 
   if (_GDSDB) 
   {
      while (wxMUTEX_NO_ERROR != GDSLock.TryLock());
      return _GDSDB;
   }
   else {
      if (throwexception) throw EXPTNactive_GDS();
      else return NULL;
   }
}
开发者ID:BackupTheBerlios,项目名称:toped-svn,代码行数:17,代码来源:datacenter.cpp


示例20: GDSparse

void DataCenter::GDSparse(std::string filename, std::list<std::string>& topcells) 
{
   if (_GDSDB) 
   {
      std::string news = "Removing existing GDS data from memory...";
      tell_log(console::MT_WARNING,news);
      GDSclose();
   }
   while (wxMUTEX_NO_ERROR != GDSLock.TryLock());
   // parse the GDS file
   _GDSDB = new GDSin::GDSFile(filename.c_str());
   if (!_GDSDB->status()) return;
   // generate the hierarchy tree of cells
   _GDSDB->HierOut();
   // add GDS tab in the browser
   browsers::addGDStab();
   GDSin::GDSHierTree* root = _GDSDB->hierTree()->GetFirstRoot();
   do 
   {
      topcells.push_back(std::string(root->GetItem()->Get_StrName()));
   } while (NULL != (root = root->GetNextRoot()));
   unlockGDS();
}
开发者ID:BackupTheBerlios,项目名称:toped-svn,代码行数:23,代码来源:datacenter.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ wxNativeFontInfo类代码示例发布时间:2022-05-31
下一篇:
C++ wxMoveEvent类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap