Implement a type-based mutex for tasks | Microsoft Interview Question