void PtrQueue::handle_zero_index() { assert(_index == 0, "Precondition."); // This thread records the full buffer and allocates a new one (while // holding the lock if there is one). if (_buf != NULL) { if (!should_enqueue_buffer()) { assert(_index > 0, "the buffer can only be re-used if it's not full"); return; } if (_lock) { assert(_lock->owned_by_self(), "Required."); // The current PtrQ may be the shared dirty card queue and // may be being manipulated by more than one worker thread // during a pause. Since the enqueuing of the completed // buffer unlocks the Shared_DirtyCardQ_lock more than one // worker thread can 'race' on reading the shared queue attributes // (_buf and _index) and multiple threads can call into this // routine for the same buffer. This will cause the completed // buffer to be added to the CBL multiple times. // We "claim" the current buffer by caching value of _buf in // a local and clearing the field while holding _lock. When // _lock is released (while enqueueing the completed buffer) // the thread that acquires _lock will skip this code, // preventing the subsequent the multiple enqueue, and // install a newly allocated buffer below. void** buf = _buf; // local pointer to completed buffer _buf = NULL; // clear shared _buf field locking_enqueue_completed_buffer(buf); // enqueue completed buffer // While the current thread was enqueuing the buffer another thread // may have a allocated a new buffer and inserted it into this pointer // queue. If that happens then we just return so that the current // thread doesn't overwrite the buffer allocated by the other thread // and potentially losing some dirtied cards. if (_buf != NULL) return; } else { if (qset()->process_or_enqueue_complete_buffer(_buf)) { // Recycle the buffer. No allocation. _sz = qset()->buffer_size(); _index = _sz; return; } } } // Reallocate the buffer _buf = qset()->allocate_buffer(); _sz = qset()->buffer_size(); _index = _sz; assert(0 <= _index && _index <= _sz, "Invariant."); }
void PtrQueue::flush() { if (!_perm && _buf != NULL) { if (_index == _sz) { // No work to do. qset()->deallocate_buffer(_buf); } else { // We must NULL out the unused entries, then enqueue. for (size_t i = 0; i < _index; i += oopSize) { _buf[byte_index_to_index((int)i)] = NULL; } qset()->enqueue_complete_buffer(_buf); } _buf = NULL; _index = 0; } }
void TimeoutMonitor::start () { QString settingsFilePath = QDir::homePath () + "/.sfviewer.config"; if( ! QFileInfo( settingsFilePath).isReadable()) throw QString("Cannot read config file %1").arg(settingsFilePath); // get database information from the INI file QSettings qset( settingsFilePath, QSettings::IniFormat); bool ok; pureWebTimeout_ = qset.value ( "timeout", DefaultPureWebTimeout).toInt ( & ok); if( ! ok) pureWebTimeout_ = DefaultPureWebTimeout; // the last timeout reset is set to current time lastTimeoutReset_.start (); dbg(1) << "Application timeout will be " << pureWebTimeout_ << " seconds.\n"; // connect this class to pure web GetStateManager().ViewManager().RegisterView( "FakeView", this); CSI::PureWeb::Server::ViewImageFormat viewImageFormat; viewImageFormat.PixelFormat = CSI::PureWeb::PixelFormat::Rgb24; viewImageFormat.ScanLineOrder = CSI::PureWeb::ScanLineOrder::TopDown; viewImageFormat.Alignment = 4; GetStateManager().ViewManager().SetViewImageFormat( "FakeView", viewImageFormat); startTimer ( 1000); }
void PendingEnvelopes::recvSCPQuorumSet(Hash hash, const SCPQuorumSet& q) { SCPQuorumSetPtr qset(new SCPQuorumSet(q)); mQsetCache.put(hash, qset); mQuorumSetFetcher.recv(hash); }
void PtrQueue::handle_zero_index() { assert(0 == _index, "Precondition."); // This thread records the full buffer and allocates a new one (while // holding the lock if there is one). void** buf = _buf; _buf = qset()->allocate_buffer(); _sz = qset()->buffer_size(); _index = _sz; assert(0 <= _index && _index <= _sz, "Invariant."); if (buf != NULL) { if (_lock) { locking_enqueue_completed_buffer(buf); } else { qset()->enqueue_complete_buffer(buf); } } }
void PendingEnvelopes::recvSCPQuorumSet(Hash hash, const SCPQuorumSet& q) { CLOG(TRACE, "Herder") << "Got SCPQSet " << hexAbbrev(hash); SCPQuorumSetPtr qset(new SCPQuorumSet(q)); mQsetCache.put(hash, qset); mQuorumSetFetcher.recv(hash); }
int main(int c, char **v) { QApplication app(c,v); //qlist(); qset(); return app.exec(); }
void PendingEnvelopes::addSCPQuorumSet(Hash hash, const SCPQuorumSet& q) { assert(isQuorumSetSane(q, false)); CLOG(TRACE, "Herder") << "Add SCPQSet " << hexAbbrev(hash); SCPQuorumSetPtr qset(new SCPQuorumSet(q)); mQsetCache.put(hash, qset); mQuorumSetFetcher.recv(hash); }
void PtrQueue::locking_enqueue_completed_buffer(void** buf) { assert(_lock->owned_by_self(), "Required."); // We have to unlock _lock (which may be Shared_DirtyCardQ_lock) before // we acquire DirtyCardQ_CBL_mon inside enqeue_complete_buffer as they // have the same rank and we may get the "possible deadlock" message _lock->unlock(); qset()->enqueue_complete_buffer(buf); // We must relock only because the caller will unlock, for the normal // case. _lock->lock_without_safepoint_check(); }
CellMLTab::CellMLTab(QWidget* parent) : ChangeableTextBox(parent), m_modelname("") { m_filetypes = "CellML files (*.xml *.cellml);;All files(*.*)"; m_extension = ".cellml"; QSettings qset(ORG, APP); qset.sync(); QFont defaultfont; defaultfont.setFamily("Courier New"); defaultfont.setPointSize(10); QFont newfont; newfont.fromString(qset.value("xmlfont", defaultfont).toString()); setFont(newfont); }