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
if c.ack != nil && logId > c.ack.id {
select {
case c.ack.ch <- logId:
default:
}
asyncNotifyUint64(c.ack.ch, logId)
c.ack = nil
}

View File

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