v/GTT
1
0
mirror of https://github.com/eeeXun/GTT.git synced 2025-05-17 08:10:22 -07:00
eeeXun 8ddd42b431 refactor: using in TTSLock in bool instead of int8
There should only one thread in TTSLock. bool is enough.
2023-04-07 20:27:51 +08:00

36 lines
458 B
Go

package core
type TTSLock struct {
using bool
stop bool
}
func NewTTSLock() *TTSLock {
return &TTSLock{
stop: true,
using: false,
}
}
func (l *TTSLock) LockAvailable() bool {
return l.stop && !l.using
}
func (l *TTSLock) AcquireLock() {
l.stop = false
l.using = true
}
func (l *TTSLock) IsStopped() bool {
return l.stop
}
func (l *TTSLock) StopTTS() {
l.stop = true
}
func (l *TTSLock) ReleaseLock() {
l.stop = true
l.using = false
}