lib/tevent: Add a thread-safe tevent backend