Global code ovehaul - remove CAS and other, add 15 minute greet check
- Remove CAS, as it no longer works for us - Remove other checks - Implement 15 minute greet timeout check - Fix chat logos - Ditch thirdparty logger, use stdlib log facility wrapper for logging
This commit is contained in:
36
internal/moon/worker.go
Normal file
36
internal/moon/worker.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package moon
|
||||
|
||||
// The worker registry: how a background goroutine joins the shutdown sequence,
|
||||
// and how it leaves it. The state itself lives in globals.go with the rest of the
|
||||
// package-level variables; this file holds only what a goroutine does with it.
|
||||
|
||||
// stopWorker unregisters a background goroutine that has finished.
|
||||
func stopWorker() {
|
||||
runningWorkers.Add(-1)
|
||||
workers.Done()
|
||||
}
|
||||
|
||||
// workerRunning reports whether any registered worker is still running.
|
||||
func workerRunning() bool {
|
||||
return runningWorkers.Load() > 0
|
||||
}
|
||||
|
||||
// startWorker registers a background goroutine with the shutdown sequence and
|
||||
// reports whether it may run. It returns false once shutdown has begun, in
|
||||
// which case the caller must return without starting: the stop signal is
|
||||
// already closed and the teardown may already have closed what it would use.
|
||||
func startWorker() bool {
|
||||
workersMu.Lock()
|
||||
defer workersMu.Unlock()
|
||||
|
||||
if stopping {
|
||||
return false
|
||||
}
|
||||
|
||||
workers.Add(1)
|
||||
runningWorkers.Add(1)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/* vim: set ft=go noet ai ts=4 sw=4 sts=4: */
|
||||
Reference in New Issue
Block a user