openvenues / gopostal

Go (cgo) interface to libpostal for fast international address parsing/normalization
MIT License
160 stars 32 forks source link

Wrapping calls containing CGo sections in a mutex #8

Closed albarrentine closed 7 years ago

albarrentine commented 7 years ago

While crossing the CGo boundary ensures that a goroutine is not swapped from one OS thread to another (via LockOSThread), it's still possible, under high concurrency, for multiple OS threads to access a CGo section at the same time. Adding mutexes to ensure that doesn't happen as libpostal is not thread-safe.