Lock-free messaging system using function pointers