Results 1 to 6 of 6

Thread: workerThread calling static QVector - will freeze if not running for many hours

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2017
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default workerThread calling static QVector - will freeze if not running for many hours

    I have a application that parses a UDP stream. Then monitor that stream for a trigger event to start my thread. within that thread is a worker thread that calls a function which contains a static QVector. On every trigger event I initiate a vector.swap and vector.resize/reserve (have used both with same results).

    with the program running and continually receiving UDP data. It runs beautifully with not issues. This data is then written to MySQL. a second thread is also running and writing reference data to another table in MySQL. Both MySQL write functions are on separate connections.

    However if my program is left running overnight with no UPD stream. My program will hang and must be re-started to work again. This is not the case with 4 hours of no UDP. I have not determined a specific time as of yet. Not sure if my issue id with my Thread or my Vector. The 2nd thread function will pick up and continue to run normally.

    Below are a few code snippets.

    System Windows 7 Prof.
    creator 4.1.0
    Qt 5.6.2(Gcc 6.1.0, 64 bit)
    using C++11

    Qt Code:
    1. [Main Thread]
    2. {
    3. frmThread = new QThread;
    4. workerThread = new StreamToVector();
    5. workerThread->moveToThread(frmThread);
    6. connect(workerThread, &DataStreamToVector::destroyed, frmThread, &QThread::quit);
    7. connect(workerThread, &DataStreamToVector::destroyed, workerThread, &DataStreamToVector::deleteLater);
    8. connect(this, &DataStreamToBuffer::DataToVector_Signal, workerThread, &DataStreamToVector::parseStreamToVector_Slot, Qt::DirectConnection);
    9. frmThread->start();
    10.  
    11. DataToVector_Signal(dataStream, dataSize, RecordsPerTriggerEvent);
    12. }
    13.  
    14. [worker thread .h ]
    15. QThread *frmThread;
    16.  
    17. [worker thread .cpp ]
    18. void DataStreamToVector::parseStreamToVector_Slot(QString dataStream, int dataSize, uint RecordsPerTriggerEvent)
    19. {
    20. static QVector < QVector<QString> > cycleBuffer(63, QVector<QString>(MAX_CYCLE_SIZE_x10MS));
    21. static uint recordCnt = 1;
    22.  
    23. if ( recordCnt > RecordsPerTriggerEvent ) {
    24. QVector < QVector<QString> > defaultBuffer(63, QVector<QString>(MAX_CYCLE_SIZE_x10MS));
    25. recordCnt = 1;
    26. cycleBuffer.swap(defaultBuffer);
    27. cycleBuffer.reserve(GALIL_40x0_ADDRESS_COUNT);
    28. }
    29.  
    30. if ( recordCnt <= recPerCycle ) {
    31. cycleBuffer[0][recordCnt].append(dataStream.mid( 12,2 )); // general Input Block 0 address
    32. cycleBuffer[1][recordCnt].append(dataStream.mid( 14,2 ));
    33. // recordCnt typically 350 - 800
    34.  
    35. if ( recordCnt == RecordsPerTriggerEvent )
    36. writeRecordsToDB(RecordsPerTriggerEvent, cycleBuffer);
    37.  
    38. recordCnt++;
    39. }
    To copy to clipboard, switch view to plain text mode 

    any insight or direction would be appreciated. Thank You,
    Last edited by swankster; 28th August 2017 at 15:45.

Similar Threads

  1. Replies: 1
    Last Post: 21st February 2014, 17:33
  2. X process 99% after 2 hours using drawPixmap
    By gab74 in forum Qt Programming
    Replies: 6
    Last Post: 24th January 2013, 18:02
  3. How do i get the number of hours
    By ayanda83 in forum Newbie
    Replies: 2
    Last Post: 4th January 2013, 10:21
  4. Replies: 5
    Last Post: 2nd September 2011, 23:11
  5. Date and hours
    By kjiu in forum Qt Programming
    Replies: 9
    Last Post: 13th November 2009, 18:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.