Merge pull request #17 from michalpristas/master

int63 changed to int32
This commit is contained in:
Chzyer 2015-11-20 17:14:10 +08:00
commit ee4d466b62
1 changed files with 6 additions and 6 deletions

View File

@ -13,11 +13,11 @@ type Terminal struct {
cfg *Config cfg *Config
state *terminal.State state *terminal.State
outchan chan rune outchan chan rune
closed int64 closed int32
stopChan chan struct{} stopChan chan struct{}
kickChan chan struct{} kickChan chan struct{}
wg sync.WaitGroup wg sync.WaitGroup
isReading int64 isReading int32
} }
func NewTerminal(cfg *Config) (*Terminal, error) { func NewTerminal(cfg *Config) (*Terminal, error) {
@ -72,7 +72,7 @@ func (t *Terminal) ReadRune() rune {
} }
func (t *Terminal) IsReading() bool { func (t *Terminal) IsReading() bool {
return atomic.LoadInt64(&t.isReading) == 1 return atomic.LoadInt32(&t.isReading) == 1
} }
func (t *Terminal) KickRead() { func (t *Terminal) KickRead() {
@ -94,10 +94,10 @@ func (t *Terminal) ioloop() {
buf := bufio.NewReader(Stdin) buf := bufio.NewReader(Stdin)
for { for {
if !expectNextChar { if !expectNextChar {
atomic.StoreInt64(&t.isReading, 0) atomic.StoreInt32(&t.isReading, 0)
select { select {
case <-t.kickChan: case <-t.kickChan:
atomic.StoreInt64(&t.isReading, 1) atomic.StoreInt32(&t.isReading, 1)
case <-t.stopChan: case <-t.stopChan:
return return
} }
@ -143,7 +143,7 @@ func (t *Terminal) Bell() {
} }
func (t *Terminal) Close() error { func (t *Terminal) Close() error {
if atomic.SwapInt64(&t.closed, 1) != 0 { if atomic.SwapInt32(&t.closed, 1) != 0 {
return nil return nil
} }
t.stopChan <- struct{}{} t.stopChan <- struct{}{}