matryer / Resync
Licence: mit
sync.Once with Reset()
Stars: ✭ 50
Programming Languages
go
31211 projects - #10 most used programming language
resync
sync.Once
with Reset()
- See sync.Once
Rather than adding this project as a dependency, consider dropping this file into your project.
Example
The following example examines how resync.Once
could be used in a HTTP server situation.
// use it just like sync.Once
var once resync.Once
// handle a web request
func handleRequest(w http.ResponseWriter, r *http.Request) {
once.Do(func(){
// load templates or something
})
// TODO: respond
}
// handle some request that indicates things have changed
func handleResetRequest(w http.ResponseWriter, r *http.Request) {
once.Reset() // call Reset to cause initialisation to happen again above
}
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].