summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qringbuffer_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Replace Q_DECL_NOEXCEPT with noexcept in corelibAllan Sandfeld Jensen2019-04-031-7/+7
| | | | | | | In preparation of Qt6 move away from pre-C++11 macros. Change-Id: I44126693c20c18eca5620caab4f7e746218e0ce3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRingBuffer: replace some checks with assertsAlex Trotsenko2018-01-101-2/+3
| | | | | | | | To avoid the silent exits and potentially dangerous output values, the caller must supply the correct parameters on input. Change-Id: Ia9c56940adbf4ad34605a002dfc5c86b32c4658c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QRingBuffer: avoid reallocations of the dataAlex Trotsenko2017-12-301-16/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since its initial implementation, QRingBuffer had the following fragilities in the architecture: - it does not guarantee validity of the pointers, if new data will be appended. As an example, passing an address of the QRingBuffer chunk as a parameter to the WriteFileEx() function on Windows requires the stability of the pointer. So, we can't add new data to the QRingBuffer until the overlapped operation completed (related issues were fixed for QWindowsPipeWriter and QSerialPort in 5.6 branch by introducing an intermediate byte array); - inefficient reallocations in reserve(), if a shared chunk was inserted in the queue (we can get a reallocation in the place where we don't expect it: char *writePtr = buffers.last().data() + tail; <- line #133 ). Proposed solution is to avoid reallocation by allocating a new block instead. That was accomplished by introducing a QRingChunk class which operates on a fixed byte array and implements head/tail pointers strategy for each individual buffer in the queue. So, QRingBuffer is no longer dependent on QByteArray's internal shrink/growth algorithms. Change-Id: I05abab0ad78e22e4815a196037dfc6eff85325d1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace Q_NULLPTR with nullptr where possibleKevin Funk2017-09-191-1/+1
| | | | | | | | | | | | | Remaining uses of Q_NULLPTR are in: src/corelib/global/qcompilerdetection.h (definition and documentation of Q_NULLPTR) tests/manual/qcursor/qcursorhighdpi/main.cpp (a test executable compilable both under Qt4 and Qt5) Change-Id: If6b074d91486e9b784138f4514f5c6d072acda9a Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Sprinkle Q_DECLARE_TYPEINFO on types used in containersGiuseppe D'Angelo2017-02-231-0/+2
| | | | | Change-Id: I6c71ed8c20cd5e785037ad25c2d3da8994e8e3a0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRingBuffer: allow to change the chunk size of the buffer dynamicallyAlex Trotsenko2016-07-231-0/+8
| | | | | | Change-Id: I0ac55713c7bb8c48d2c9c774376543caef781980 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make sure all private headers in Qt Core include qglobal_p.hThiago Macieira2016-06-251-0/+1
| | | | | | | | | | | | The rule was: - if the header included qglobal.h, turn that into qglobal_p.h - otherwise, insert the #include after the "We mean it" warning qglobal_p.h currently only includes qglobal.h. Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QRingBuffer: add append(const char *, qint64) functionAlex Trotsenko2016-02-011-0/+1
| | | | | | | This allows to remove a code duplication in several places. Change-Id: I49f56e951682dbd2968923654a12cba5199a2502 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Integrate QProcess into QIODevice's multistreaming infrastructureAlex Trotsenko2016-01-291-1/+5
| | | | | | | | As a result, this patch eliminates double-buffering in QProcess. Change-Id: I436faa4a5ffc28ce77f959dd6089bef400ac39f6 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Allow to use QRingBuffer in containersAlex Trotsenko2016-01-121-1/+1
| | | | | | | Make a private member mutable to enable default assignment operator. Change-Id: I1216875c186ed800e07c6b41a5bae18c3b71b2fa Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* QRingBuffer: improve skip() performanceAlex Trotsenko2015-10-201-1/+4
| | | | | | | Use free() instead of read(0, length) call. Change-Id: I284e2099a3fb639cb40525ae2ca7fea0d09a620f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* QRingBuffer: avoid allocation in c'torAlex Trotsenko2015-08-271-3/+1
| | | | | | | | | | | | | | | | | | Reduces creation time and memory consumption when the buffer is unused. Robin's benchmark: QBENCHMARK { QFile file(filename); } reports the following results (run with -median 10 -iterations 524288): before: 0.00028 msecs per iteration (total: 149, iterations: 524288) after: 0.00017 msecs per iteration (total: 93, iterations: 524288). Change-Id: Ied4e7caeca794b94260b8fc59b3ba656f4719c30 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* QRingBuffer: allow to search from any positionAlex Trotsenko2015-08-271-1/+1
| | | | | | Change-Id: I348cd9da88fc81c3dd0789ce8cce9d80c4524e24 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRingBuffer: merge indexOf() overloadsAlex Trotsenko2015-05-281-1/+1
| | | | | Change-Id: Icfed4a29bc2ac95b3e0300eb4579751fe7e57e77 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Deinline QRingBuffer classAlex Trotsenko2015-05-201-243/+23
| | | | | | | | Reduce the size of .text section in QtCore by 4.5KB and in QtNetwork by 26.5KB. Change-Id: If7998776166b9681c1e4b24c51d40444aa996d7a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* QRingBuffer: allow to peek bytes from any positionAlex Trotsenko2015-04-101-0/+24
| | | | | | | | Add an ordinary peek() function which also allows retrieving data from a specified position. We need this functionality in several places. Change-Id: Ia4a1b6fe1d7f76cb8f6f1ea34b3e4b89e05a2a68 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QRingBuffer a 64-bit safeAlex Trotsenko2015-03-121-28/+34
| | | | | | | | | | | According to I/O API, QIODevice and its inherited classes should be able to process a full 64-bit offsets and lengths. This requires 64-bit parameters in operations with internal buffers. Rework QRingBuffer to avoid implicit truncation of numbers and fix some 64-bit issues in code. Change-Id: Iadd6fd5fefd2d64e6c084e2feebb4dc2d6df66de Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* QRingBuffer: retrieve pointer to data more carefullyAlex Trotsenko2015-01-091-1/+1
| | | | | | | | | | | An empty ring buffer always has a pre-cached byte array in its container. In this case size() indicates that no data is available, but readPointer() tries to resolve this byte array. To avoid an illegal pointer as a result, return Q_NULLPTR instead. Change-Id: Icc5f08f071a8f02a14c112b6e1adbe5373bd9466 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify QRingBuffer::isEmpty()Alex Trotsenko2014-12-061-1/+1
| | | | | | | Also, make it consistent with size(). Change-Id: Ie5285e3c07ebba2d2eea05a80a75ce148da47d7b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* QRingBuffer: cache the last released blockAlex Trotsenko2014-12-021-8/+26
| | | | | | | | | | A typical ring buffer usage is a sequence of reserve()->chop()->read() cycles. Usually, between these cycles, the buffer doesn't contain data and all blocks are released. To reduce reallocations, keep the most recently used block while the buffer is empty. Change-Id: I8128f1f04649ae005fd0a480f17f95de01a9a135 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* QRingBuffer: optimize memory usageAlex Trotsenko2014-11-261-1/+1
| | | | | | | | | QByteArray resizing behavior is to preallocate a certain amount of memory for future growth. Make QRingBuffer aware of the extra capacity in QByteArray. Change-Id: I68310d5783fbc32e4fd5075ed3269ce6b7128a92 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QRingBuffer::ungetChar() not leave empty array in buffer listAlex Trotsenko2014-10-131-2/+6
| | | | | Change-Id: Ic692693132f0c316ad068cad5423ca8fd32bd40d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Rewrite QRingBufferAlex Trotsenko2014-07-241-191/+88
| | | | | | | | | QRingBuffer is a fully inlined class used in many I/O classes. So, it must be as fast and small as possible. To this end, a lot of unnecessary special cases were replaced by generic structures. Change-Id: Ic189ced3b200924da158ce511d69d324337d01b6 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Make QRingBuffer::append() not leave empty arrays in buffer listAlex Trotsenko2014-07-231-3/+7
| | | | | Change-Id: I4c5af33488a70996299289ec2b953b7bf3b2c428 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* QRingBuffer: purge unused part of the apiAlex Trotsenko2014-07-181-33/+0
| | | | | | | Remove unused and untested class functions. Change-Id: I8eb963db0ae4be9b5cdde91f6747c4a1db4ea649 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Fix QRingBuffer::readPointerAtPosition()Alex Trotsenko2014-06-241-1/+1
| | | | | | | Fix condition to allow return a valid pointer when head != 0. Change-Id: I5215f7dfc44924016c2d9b67ab2d9935b5164d7a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Whitespace cleanup: remove trailing whitespaceAxel Waggershauser2013-03-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Remove all trailing whitespace from the following list of files: *.cpp *.h *.conf *.qdoc *.pro *.pri *.mm *.rc *.pl *.qps *.xpm *.txt *README excluding 3rdparty, test-data and auto generated code. Note A): the only non 3rdparty c++-files that still have trailing whitespace after this change are: * src/corelib/codecs/cp949codetbl_p.h * src/corelib/codecs/qjpunicode.cpp * src/corelib/codecs/qbig5codec.cpp * src/corelib/xml/qxmlstream_p.h * src/tools/qdoc/qmlparser/qqmljsgrammar.cpp * src/tools/uic/ui4.cpp * tests/auto/other/qtokenautomaton/tokenizers/* * tests/benchmarks/corelib/tools/qstring/data.cpp * util/lexgen/tokenizer.cpp Note B): in about 30 files some overlapping 'leading tab' and 'TAB character in non-leading whitespace' issues have been fixed to make the sanity bot happy. Plus some general ws-fixes here and there as asked for during review. Change-Id: Ia713113c34d82442d6ce4d93d8b1cf545075d11d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* QRingBuffer: make constructor explicitMarc Mutz2012-02-291-1/+1
| | | | | | | | | | | | | | This is a private class, but it's so close to the classical Stack(int) example for explicit that I just have to make this ctor explicit, too: QRingBuffer rb = 0; // oops: meant '*rb' now no longer compiles. Change-Id: I7d58c1f08c1b14d14930426159c5c8db71b4cf4d Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+451
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12