AsyncMessenger: Async event threads shared by all AsyncMessenger

WorkerPool is a singleton class which is served to AsyncMessenger. All
AsyncMessenger used the same worker pool.

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncConnection: Ensure "mark_down" complete when returned

Now AsyncConnection try to process or modify any own variables within self
thread. It means actual function will be called by event loop not external.
So we can avoid lockdep or unnecessary lock for AsyncConnection.

So "mark_down" should be returned after _stop completed and all events has
be processed.

"external" for unregister_conn is unnecessary, because the caller won't
own AsyncMessenger::Lock again.

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncConnection: Introduce "signal" event

Ensure signal cond after all previous events has be done

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
Event: Fix Coverity error

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncConnection: Avoid deadlock for AsyncConnection::lock

accept and connection will be send to queue and deliver to dispatcher. So
it can avoid caller stuck into AsyncConnection::lock deadlock

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncConnection: Skip delete_file_event if sd < 0

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncMessenger: Fix thread destroy when no active Messenger

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
CephContext: Add AssociatedSingletonObject to allow CephContext's singleton

If some objects associated to CephContext want to create a singleton object,
it can inherit AssociatedSingletonObject and implement destruction to get notified.

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
AsyncMessenger: Make WorkerPool use CephContext's singleton

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
Merge pull request #2987 from yuyuyu101/wip-9888

AsyncMessenger: Async event threads can shared by all AsyncMessenger

Reviewed-by: Sage Weil <sage@redhat.com>