C++ EventHandler Class
RAII

Whenever you need to acquire a resource, hold it for a while, and then release it deterministically - think resource acquisition is initialization. RAII! When I look at your equality comparison:

bool operator== (const EventHandler&amp; other)
{
    while (m_flag.test_and_set(std::memory_order_acquire));
    bool equal = (m_ptr == other.m_ptr);
    m_flag.clear(std::memory_order_release);
    return equal;
}


We're really doing two things. We're acquiring and releasing a lock on m_flag, and then we're doing the equality comparison. So let's make that a lot more explicit. 

std::lock_guard is an RAII lock, templated on a BasicLockable - which is just a class that supports a lock() and unlock(). So instead of holding a std::atomic_flag member, we can hold a member of type:

struct FlagMutex {
    void lock() {
        while (m_flag.test_and_set(std::memory_order_acquire));
    }

    void unlock() {
        m_flag.clear(std::memory_order_release);
    }

    /*
     * note that you were not initializing your flag correctly!
     */
    std::atomic_flag m_flag = ATOMIC_INIT_FLAG;
};


And then our equality operator becomes:

bool operator== (const EventHandler&amp; other) {
    std::lock_guard&lt;FlagMutex&gt; lk(m_mutex);
    return m_ptr == other.m_ptr;
}


Keep that in mind throughout. Furthermore, if you do it this way, then FlagMutex can become a template argument for EventHandler so you can actually test the assertion that a std::atomic_flag is faster than a std::mutex.

Generalize Your Class

Right now, your event handler is constructible with:

template &lt;typename _Type&gt;
EventHandler(void (_Type::*memFn)(_EventArg), _Type *obj)


But why limit to just member functions? Your class has a std::function member. That can support free functions. Just generalize it.

Additionally, prefer make_shared to just new:

using FuncType = std::function&lt;void(_EventArg)&gt;;

template &lt;typename F,
          typename = std::enable_if_t&lt;
              std::is_constructible&lt;FuncType(F&amp;&amp;)&gt;::value
          &gt;&gt;
EventHandler(F&amp;&amp; func)
{
    m_ptr = std::make_shared&lt;FuncType&gt;(std::forward&lt;F&gt;(func));
}


The user can pass in a bind expression if they want, or a lambda, or any number of other things. Just lets you do more things. 

Also _EventArg is a reserved name.