| 1 |
package mode |
| 2 |
|
| 3 |
import "sync/atomic" |
| 4 |
|
| 5 |
// noquit is a counter for goroutines that requested the no-quit mode |
| 6 |
var noquit int32 |
| 7 |
|
| 8 |
// NoQuit enters no-quit mode where aerc cannot be exited (unless the force |
| 9 |
// option is used) |
| 10 |
func NoQuit() { |
| 11 |
atomic.AddInt32(&noquit, 1) |
| 12 |
} |
| 13 |
|
| 14 |
// NoQuitDone leaves the no-quit mode |
| 15 |
func NoQuitDone() { |
| 16 |
atomic.AddInt32(&noquit, -1) |
| 17 |
} |
| 18 |
|
| 19 |
// QuitAllowed checks if aerc can exit normally (only when all goroutines that |
| 20 |
// requested a no-quit mode were done and called the NoQuitDone() function) |
| 21 |
func QuitAllowed() bool { |
| 22 |
return atomic.LoadInt32(&noquit) <= 0 |
| 23 |
} |