示例#1
0
func (s *SerializedBuffer) Index(i int) rune {
	s.ops <- func() interface{} { return s.inner.Index(i) }
	r := <-s.lockret
	if r2, ok := r.(rune); ok {
		return r2
	} else {
		log4go.Error("Error: %v", r)
		return 0
	}
}
示例#2
0
func (s *SerializedBuffer) SubstrR(re Region) []rune {
	s.ops <- func() interface{} { return s.inner.SubstrR(re) }
	r := <-s.lockret
	if r2, ok := r.([]rune); ok {
		return r2
	} else {
		log4go.Error("Error: %v", r)
		return nil
	}
}
示例#3
0
func (s *SerializedBuffer) TextPoint(row, col int) (i int) {
	s.ops <- func() interface{} { return s.inner.TextPoint(row, col) }
	r := <-s.lockret
	if r2, ok := r.(int); ok {
		return r2
	} else {
		log4go.Error("Error: %v", r)
		return 0
	}
}
示例#4
0
func (s *SerializedBuffer) RowCol(point int) (row, col int) {
	s.ops <- func() interface{} { r, c := s.inner.RowCol(point); return [2]int{r, c} }
	r := <-s.lockret
	if r2, ok := r.([2]int); ok {
		return r2[0], r2[1]
	} else {
		log4go.Error("Error: %v", r)
		return 0, 0
	}
}
示例#5
0
func (s *SerializedBuffer) worker() {
	for o := range s.ops {
		func() {
			defer func() {
				if r := recover(); r != nil {
					log4go.Error("Recovered from panic: %v, %s", r, debug.Stack())
					s.lockret <- r
				}
			}()
			s.lockret <- o()
		}()
	}
	// Done processing all ops, so freeing the other resources here
	s.inner = nil
	close(s.lockret)
}