[mlir] Support thread-safe context access without parallel execution (#236551)
Add enableThreadSafeLocking() and isThreadSafeLockingEnabled() so
clients using external threads can unique context-owned entities without
enabling MLIR parallel execution or creating a thread pool. Use the
locking mode for operation-name uniquing as well as the type, attribute,
and affine uniquers. Enabling multithreading also enables locking.
Follow-up to #235294.
Assisted-by: Codex