Team: Firmware Group
2 technical interviews back to back, was asked:
- concurrency:
Multiple threads call a reg_cb function at any time. Another thread can call an API trigger_event which triggers an event to happen. Once the event happens, all callbacks that were registered should be called. Any new callbacks that are registered through reg_cb should be called instantly. Implement the reg_cb and
█████████████████
█████████████████████████████████████████████████████████████████
█████████████████████████████████████████████████████████████████
██████████████████████████████████████████
███████████████████████████
█████████████████████████████████████████████████████████████████
███████████████
███████████████
███████████████
█████████████████
████████████████████████
█████████████████████████████
████████████████████████████████
█████████████████████████
██████████████████████
█████████████████████████████████████████████████████████████████
███████████████
███████████████
███████████████
█████████████████████
█████████████████
████████████████████████████
██████████████████████████████████████████████████████████████
██████████████████████████████████████