use a context so we dont have to take slow paths for thread safety.

this allows you to initialize a context that will be thread safe, at
the cost of some performance. also, it allows for disabling the host
cache and pid cache if you intend to use it after a fork.