// goroutine safe
556184
func (s *Server) CallN(id interface{}, args ...interface{}) ([]interface{}, error) {
	return s.Open(0).CallN(id, args...)
}
253030
func (s *Group) Go(fn func() error) {
	s.g.Go(func() error {
		s.ch <- true
		defer func() {
			<-s.ch
		}()
		return fn()
	})
}
628163
func (mrr *MultiRoutineRunner) Run(fn func()) {
	mrr.once.Do(mrr.init)
	mrr.q <- fn
}
1034100
func Safe(fn func(), r Recovery) {
	defer func() {
		if e := recover(); e != nil {
			handlePanic(r, e)
		}
	}()
	fn()
}
185043
func (gs *Server) StartRoutine() {
	gs.wg.Add(1)
	atomic.AddInt32(&gs.routinesCount, 1)
}
1001407
func goErrorHandler(code C.int, reason *C.char) {
	reasonHeader := reflect.StringHeader{
		Data: uintptr(unsafe.Pointer(reason)),
		Len:  int(C.strlen(reason)),
	}
	reasonString := (*string)(unsafe.Pointer(&reasonHeader))
	Log.Printf("%s -- %s", codeToString(int(code)), *reasonString)
}
471192
func (g *lockedNetNSGoroutine) run(f func()) {
	done := make(chan struct{})
	g.funcC <- func() {
		defer close(done)
		f()
	}
	<-done
}
1095454
func (m *mater) Go(g1, g2 *IGenome) (IGenome, IGenome) {

	newG1 := NewGenome(*(*g1).GetBits())
	newG2 := NewGenome(*(*g2).GetBits())
	for _, config := range m.materConfig {
		if rand.Float32() < config.P {
			if config.UseElite {
				newG1, newG2 = config.F(&newG1, m.elite)
			} else {
				newG1, newG2 = config.F(&newG1, &newG2)
			}
		}
	}

	return newG1, newG2
}
819710
func (g *group) Go(f func()) {
	g.wg.Add(1)
	go func() {
		defer g.wg.Done()
		f()
	}()
}
763787
func (h *HistoryProvider) Go(path string) {
	if h.usingHash {
		SetDOMHash(path)
		return
	}
	PushDOMState(path)
}
1291749
func (client *BaseClient) Go(
	name string,
	args []reflect.Value,
	settings *InvokeSettings,
	callback Callback) {
	go func() {
		defer client.fireErrorEvent(name, nil)
		callback(client.Invoke(name, args, settings))
	}()
}
92261
func GoRoutineID() uint64 {
	b := make([]byte, 64)
	b = b[:runtime.Stack(b, false)]
	b = bytes.TrimPrefix(b, []byte("goroutine "))
	b = b[:bytes.IndexByte(b, ' ')]
	n, _ := strconv.ParseUint(string(b), 10, 64)
	return n
}
412972
func (srv *Server) loop(ready chan struct{}) error {
	// for pat based handlers, they are matched in-order of being
	// registered, first match wins. So more specific ones have to be
	// registered first.
	for _, ep := range srv.endpoints() {
		srv.mux.AddHandler(ep.Method, ep.Pattern, ep.Handler)
		defer srv.mux.RemoveHandler(ep.Method, ep.Pattern)
		if ep.Method == "GET" {
			srv.mux.AddHandler("HEAD", ep.Pattern, ep.Handler)
			defer srv.mux.RemoveHandler("HEAD", ep.Pattern)
		}
	}
	close(ready)
	<-srv.tomb.Dying()
	srv.wg.Wait() // wait for any outstanding requests to complete.
	return tomb.ErrDying
}
560379
func Run(jobs []Tasker) (err error) {
	// []T does not convert to []Tasker implicitly even is T implements
	// Tasker. We need to iterate on []Tasker making an explicit cast.
	// http://golang.org/doc/faq#convert_slice_of_interface
	prematureEnd := make(chan struct{})
	jobsQueue := make(chan Tasker, workersNumber)
	done := make(chan struct{}, workersNumber)
	var totalDone int
	go populateQueue(jobsQueue, jobs, prematureEnd)
	go parallelizeWorkers(jobsQueue, done)
	// TODO add a case timeout that returns error.
	for {
		select {
		case <-done:
			totalDone++
		case <-prematureEnd:
			err = ErrTasksNotCompleted
		}
		if totalDone == workersNumber {
			// We can assume that jobsQueue is closed and
			// that no goroutine is operating on []Tasker.
			break
		}
	}
	return
}
650907
func init() {
	historicUsage = &Usage{}
	var cycles uint64
	go func() {
		for {
			time.Sleep(memUsageMeasureInterval)
			currUsage := GetUsage()
			currSum := cycles * historicUsage.Mem
			cycles = cycles + 1
			historicUsage.Mem = (currSum + currUsage.Mem) / cycles
		}
	}()
}
381113
func (gs *Server) FinishRoutine() {
	gs.wg.Done()
	atomic.AddInt32(&gs.routinesCount, -1)
}
1041406
func go_callback(queueId C.int, data *C.uchar, length C.int, idx uint32, vc* VerdictContainerC) {
	xdata := C.GoBytes(unsafe.Pointer(data), length)

	var packet gopacket.Packet
	if xdata[0] & 0xf0 == ipv4version {
		packet = gopacket.NewPacket(xdata, layers.LayerTypeIPv4, gopacket.DecodeOptions{Lazy: true, NoCopy: true})
	} else {
		packet = gopacket.NewPacket(xdata, layers.LayerTypeIPv6, gopacket.DecodeOptions{Lazy: true, NoCopy: true})
	}

	p := NFPacket{
		verdictChannel: make(chan VerdictContainer),
		Packet: packet,
	}

	theTabeLock.RLock()
	cb, ok := theTable[idx]
	theTabeLock.RUnlock()
	if !ok {
		fmt.Fprintf(os.Stderr, "Dropping, unexpectedly due to bad idx=%d\n", idx)
		(*vc).verdict = C.uint(NF_DROP)
		(*vc).data = nil
		(*vc).length = 0
	}
	select {
		case *cb <- p:
			select {
				case v := <-p.verdictChannel:
					if v.Packet == nil {
						(*vc).verdict = C.uint(v.Verdict)
						(*vc).data = nil
						(*vc).length = 0
					} else {
						(*vc).verdict = C.uint(v.Verdict)
						(*vc).data = (*C.uchar)(unsafe.Pointer(&v.Packet[0]))
						(*vc).length = C.uint(len(v.Packet))
					}
			}

		default:
			fmt.Fprintf(os.Stderr, "Dropping, unexpectedly due to no recv, idx=%d\n", idx)
			(*vc).verdict = C.uint(NF_DROP)
			(*vc).data = nil
			(*vc).length = 0
	}
}