channelstorage_cpp_map_name_id.cc: Refactor iterators for thread-safety.
The fact that deleting an object from a map invalidates any iterator
that happens to currently point to that object was overlooked in the initial
implementation. Unfortunately, there's no way to detect that an iterator
has been invalidated so the result was an occasional SEGV triggered by modules
like app_chanspy that opens an iterator and can keep it open for a long period
of time. The new implementation doesn't keep the underlying C++ iterator
open across calls to ast_channel_iterator_next() and uses a read lock
on the map to ensure that, even for the few microseconds we use the
iterator, another thread can't delete a channel from under it. Even with
this change, the iterators are still WAY faster than the ao2_legacy
storage driver.
Full details about the new implementation are located in the comments for
iterator_next() in channelstorage_cpp_map_name_id.cc.