Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QBasicAtomicPointer usage example

QBasicAtomicPointer usage example

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 2.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    papu12
    wrote on last edited by
    #1

    Is there any example code of QBasicAtomicPointer usage --- Thanks in advance

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      AFAIK QBasicAtomicPointer is an internal class and should not be used.

      If you need something like that you should use QAtomicPointer

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        papu12
        wrote on last edited by
        #3

        Thanks .I made changes as suggested by you:
        @
        #if QT_VERSION < QT_VERSION_CHECK(4, 4, 0)
        #define LOG4QT_DECLARE_STATIC_LOGGER(FUNCTION, CLASS)
        static Log4Qt::Logger *FUNCTION()
        {
        static Log4Qt::Logger *p_logger = 0;
        if (!p_logger)
        {
        q_atomic_test_and_set_ptr(
        &p_logger,
        0,
        Log4Qt::Logger::logger( #CLASS ));
        }
        return p_logger;
        }
        #else
        #define LOG4QT_DECLARE_STATIC_LOGGER(FUNCTION, CLASS) \

        #define LOG4QT_DECLARE_STATIC_LOGGER(FUNCTION, CLASS)                     \
            static Log4Qt::Logger *FUNCTION()                                     \
            {                                                                     \
                static QAtomicPointer<Log4Qt::Logger> p_logger ;            \
           //         Q_ATOMIC_INITIALIZER(0);                                 \
                                                                                   \
                if (!p_logger.testAndSetOrdered(0,                                 \
                        Log4Qt::Logger::logger( #CLASS )))                        \
                {                                                                 \
                    p_logger.testAndSetOrdered(0,                                 \
                    Log4Qt::Logger::logger( #CLASS ));                            \
                }                                                                 \
                return p_logger;                                                  \
        }
        

        #endif
        @

        seems this error is removed , others error pops up , looking at them.
        Thanks much.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You should first check if the current version of Log4Qt has been validated against Qt 5

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • P Offline
            P Offline
            papu12
            wrote on last edited by
            #5

            nope, its not , but we used it , so we plan to update it to make compatible with qt5

            1 Reply Last reply
            0
            • P Offline
              P Offline
              papu12
              wrote on last edited by
              #6

              also , using QAtomicPointer is not solving , still has type casting issue. Struggling with that.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                ScottR
                wrote on last edited by
                #7

                Does
                @
                return (Log4Qt::Logger*) p_logger;
                @

                work?

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved