split out cache struct and span an RWMutex around it

Authored by sitter on Jun 1 2017, 12:30 PM.

Description

split out cache struct and span an RWMutex around it

I've been doing too much ruby. Neither maps nor slices are thread safe
in golang. To prevent concurrent RW span a mutex over our cache to guard
the cache content. Performance impact seems negligible.

NB: golang got sync.Map a month ago which isn't yet released, might be
worth looking into to reduce boilerpalte a bit

NB2: this uses a QMutexLocker like approach by defering an unlock func
returned by convenience Locker/WLocker functions of the cache. This may be
a tad too smart for its own good while this is fairly fancy code it isn't
exactly obvious what the point of it is. Might get dropped in the future.

Details

Committed
sitterJun 1 2017, 12:30 PM
Parents
R860:038c3f1c1f34: document inferal test
Branches
Unknown
Tags
Unknown