use async notify

This commit is contained in:
siddontang 2014-09-24 21:31:26 +08:00
parent 0a64b592d5
commit 6d293ce152
2 changed files with 10 additions and 12 deletions

View File

@ -83,10 +83,7 @@ func syncCommand(c *client) error {
c.lastLogID = logId - 1 c.lastLogID = logId - 1
if c.ack != nil && logId > c.ack.id { if c.ack != nil && logId > c.ack.id {
select { asyncNotifyUint64(c.ack.ch, logId)
case c.ack.ch <- logId:
default:
}
c.ack = nil c.ack = nil
} }

View File

@ -54,10 +54,7 @@ func newMaster(app *App) *master {
} }
func (m *master) Close() { func (m *master) Close() {
select { ledis.AsyncNotify(m.quit)
case m.quit <- struct{}{}:
default:
}
if m.conn != nil { if m.conn != nil {
m.conn.Close() m.conn.Close()
@ -262,10 +259,14 @@ func (app *App) removeSlave(c *client) {
delete(app.slaves, c) delete(app.slaves, c)
if c.ack != nil { if c.ack != nil {
select { asyncNotifyUint64(c.ack.ch, c.lastLogID)
case c.ack.ch <- c.lastLogID: }
default: }
}
func asyncNotifyUint64(ch chan uint64, v uint64) {
select {
case ch <- v:
default:
} }
} }