Hide the state structure behind a simple API.

Use TLS to allow (not yet functional) multiple threads to submit work
concurrently.