本文整理汇总了C++中wxMutex类的典型用法代码示例。如果您正苦于以下问题:C++ wxMutex类的具体用法?C++ wxMutex怎么用?C++ wxMutex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了wxMutex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例2: 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();
}
示例3: 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;
}
示例4: 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;
}
}
示例5: 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;
}
示例6: setDatabaseFile
void AtlasImporter::setDatabaseFile( wxString s )
{
assert( sharedSection );
mutex.Lock();
sharedSection->dbfile = s;
mutex.Unlock();
}
示例7: setImportFile
void AtlasImporter::setImportFile( wxString s )
{
assert( sharedSection );
mutex.Lock();
sharedSection->sqlfile = s;
mutex.Unlock();
}
示例8: updateFilter
/*****************************************************
**
** AtlasLogic --- updateFilter
**
******************************************************/
void AtlasLogic::updateFilter()
{
mutex.Lock();
resetEntries();
assert( sharedSection );
sharedSection->countHasOrder = true;
sharedSection->fetchHasOrder = true;
mutex.Unlock();
}
示例9: 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();
}
示例10: 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();
}
示例11: 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;
}
示例12: 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;
};
示例13: 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);
}
示例14: 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
}
示例15: 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();
}