LCOV - code coverage report
Current view: top level - src - simpletransaction.cpp (source / functions) Coverage Total Hit
Test: .lcov.total Lines: 100.0 % 18 18
Test Date: 2026-03-23 21:55:57 Functions: 100.0 % 4 4

            Line data    Source code
       1              : // SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
       2              : // SPDX-License-Identifier: GPL-3.0-or-later
       3              : #include "simpletransaction.h"
       4              : #include <utility>
       5              : 
       6              : #ifdef QT_DEBUG
       7              : #include "debughelper.h"
       8              : #endif
       9              : 
      10              : using Enums::INVALID;
      11              : using Enums::PROCESS;
      12              : 
      13              : /**
      14              :  * @brief simpleTransaction::transactionStart
      15              :  */
      16          108 : void simpleTransaction::transactionStart() {
      17              : #ifdef QT_DEBUG
      18              :   dbg() << "START" << transactionDepth;
      19              : #endif
      20          108 :   transactionDepth++;
      21          108 : }
      22              : 
      23              : /**
      24              :  * @brief simpleTransaction::transactionAdd
      25              :  * @param id
      26              :  */
      27          180 : void simpleTransaction::transactionAdd(PROCESS id) {
      28              : #ifdef QT_DEBUG
      29              :   dbg() << "ADD" << transactionDepth << id;
      30              : #endif
      31          180 :   if (transactionDepth > 0) {
      32          144 :     lastInTransaction = id;
      33              :   } else {
      34              :     transactionQueue.emplace(id, id);
      35              :   }
      36          180 : }
      37              : 
      38              : /**
      39              :  * @brief simpleTransaction::transactionEnd
      40              :  * @param pid
      41              :  */
      42          108 : void simpleTransaction::transactionEnd(PROCESS pid) {
      43              : #ifdef QT_DEBUG
      44              :   dbg() << "END" << transactionDepth;
      45              : #endif
      46          108 :   if (transactionDepth > 0) {
      47          108 :     transactionDepth--;
      48          108 :     if (transactionDepth == 0 && lastInTransaction != INVALID) {
      49           72 :       transactionQueue.emplace(lastInTransaction, pid);
      50           72 :       lastInTransaction = INVALID;
      51              :     }
      52              :   }
      53          108 : }
      54              : 
      55              : /**
      56              :  * @brief simpleTransaction::transactionIsOver
      57              :  * @param id
      58              :  * @return
      59              :  */
      60           72 : auto simpleTransaction::transactionIsOver(PROCESS id) -> PROCESS {
      61              : #ifdef QT_DEBUG
      62              :   dbg() << "OVER" << transactionDepth << id;
      63              : #endif
      64           72 :   if (!transactionQueue.empty() && id == transactionQueue.front().first) {
      65           72 :     PROCESS ret = transactionQueue.front().second;
      66              :     transactionQueue.pop();
      67           72 :     return ret;
      68              :   }
      69              :   return INVALID;
      70              : }
        

Generated by: LCOV version 2.4-beta