Where possible replace apr with standard C++11 functionality

#20 Open
Repository
viewer-release_apr
Branch
default
Repository
viewer-release
Branch
default

Bitbucket cannot automatically merge this request.

The commits that make up this pull request have been removed.

Bitbucket cannot automatically merge this request due to conflicts.

Review the conflicts on the Overview tab. You can then either decline the request or merge it manually on your local system using the following commands:

hg update default
hg pull -r default https://bitbucket.org/NickyD/viewer-release_apr
hg merge 3b05fd2264a1
hg commit -m 'Merged in NickyD/viewer-release_apr (pull request #20)'
Author
  1. Nicky
Reviewers
Description
  • Remove apr from LLAtomic32 and rather use std::atomic and thus rename the class to a more generic name of LLAtomic The apr atomics had been problematic as no one ever did bother to call apr_atomic_init. This:

    • either did lead to crashes if apr was compiled to use a mutex for thread safe variable intialisation
    • or initialisation was okay, but apr did not synchronize setting the *pointer to a value.
  • Replace ARP Mutex and Condition with std::mutx and std::conditional_variable

  • Replace apr threads with std::thread.
  • Remove now unused APR pool.
  • Remove apr queue and replace it with a deque and LLMutex.
  • Because GCC 4.8 has a libstc++ that is a special snowflake and does not define std::atomic_(u)int32_t
  • More changed for gcc.

    • Need to include lltimer.h for ms_sleep
    • Fix typo in LLThreadSafeQueue<ElementT>::popBack. visual Studio did not care as method never is instantiated.
  • After input from Nat:

    • Rename LLAtomic to LLAtomicBase
    • LLAtomicBase has now only one required argument, the type to wrap. The other will be deduced as std::atomic< Type > if not supplied.
    • I did notice the forward declaration in llapp.h was not used, so away with it.
  • Change pointer to member where possible and do a bit of cleanup in lerror (move the mutexex in there and us the LLMutextTryLock rather than a custom class).

  • Use LLCondition rather than LLMutex. Then we can conveniently .wait() in popBack rather then having to use a poll loop./

Comments (2)

  1. Henri Beauchamp

    I ported this code to my viewer, using boost/atomic.hpp, boost/thread/mutex.hpp, boost/thread/locks.hpp and boost/thread/condition_variable.hpp instead of their C++11 equivalents.

    It works fine (tested under Linux with gcc v4.6.4, v4.8.5, v4.9.4, v5.5.0, v7.3.0 and clang v6.0.1, and under Windows/VS2013) and preserves the compatibility with pre-v4.9 gcc (v4.7 and v4.8 got partial/exotic C++11 support that requires hacks to properly work, and gcc v4.6 or older versions do not have the C++11 headers).

    See however my comment about the missing mLocked = false; in LLScopedLock::unlock().

    I also moved the LLAtomic stuff to its own header file (llatomic.h) since it does not have any relation any more with APR.