// ListThreads lists all threads.
332775
func (s *RPCServer) ListThreads(arg ListThreadsIn, out *ListThreadsOut) (err error) {
	out.Threads, err = s.debugger.Threads()
	return err
}
601048
func (a AzureCLI) ListClouds() ([]Cloud, error) {
	var clouds []Cloud
	if err := a.run(&clouds, "cloud", "list"); err != nil {
		return nil, errors.Trace(err)
	}
	return clouds, nil
}
68132
func (p *Process) ThreadList() []proc.Thread {
	r := make([]proc.Thread, 0, len(p.threads))
	for _, thread := range p.threads {
		r = append(r, thread)
	}
	return r
}
710062
func (k *KVS) ListKeys(args *structs.KeyListRequest, reply *structs.IndexedKeyList) error {
	if done, err := k.srv.forward("KVS.ListKeys", args, args, reply); done {
		return err
	}

	aclToken, err := k.srv.ResolveToken(args.Token)
	if err != nil {
		return err
	}

	if aclToken != nil && k.srv.config.ACLEnableKeyListPolicy && !aclToken.KeyList(args.Prefix) {
		return acl.ErrPermissionDenied
	}

	return k.srv.blockingQuery(
		&args.QueryOptions,
		&reply.QueryMeta,
		func(ws memdb.WatchSet, state *state.Store) error {
			index, keys, err := state.KVSListKeys(ws, args.Prefix, args.Seperator)
			if err != nil {
				return err
			}

			// Must provide non-zero index to prevent blocking
			// Index 1 is impossible anyways (due to Raft internals)
			if index == 0 {
				reply.Index = 1
			} else {
				reply.Index = index
			}

			if aclToken != nil {
				keys = FilterKeys(aclToken, keys)
			}
			reply.Keys = keys
			return nil
		})
}
1032779
func (a *ActionAPI) ListAll(arg params.Entities) (params.ActionsByReceivers, error) {
	if err := a.checkCanRead(); err != nil {
		return params.ActionsByReceivers{}, errors.Trace(err)
	}

	return a.internalList(arg, combine(pendingActions, runningActions, completedActions))
}
192216
func (opts PutObjectOptions) getNumThreads() (numThreads int) {
	if opts.NumThreads > 0 {
		numThreads = int(opts.NumThreads)
	} else {
		numThreads = totalWorkers
	}
	return
}
714972
func (i *Index) availableThreads() int {
	n := runtime.GOMAXPROCS(0)
	if len(i.partitions) < n {
		return len(i.partitions)
	}
	return n
}
84223
func MultithreadedSortComparators(comparators Comparators) Comparators {
	toBeSorted := make(Comparators, len(comparators))
	copy(toBeSorted, comparators)

	var wg sync.WaitGroup

	numCPU := int64(runtime.NumCPU())
	if numCPU%2 == 1 { // single core machine
		numCPU++
	}

	chunks := chunk(toBeSorted, numCPU)
	wg.Add(len(chunks))
	for i := 0; i < len(chunks); i++ {
		go func(i int) {
			sortBucket(chunks[i])
			wg.Done()
		}(i)
	}

	wg.Wait()
	todo := make([]Comparators, len(chunks)/2)
	for {
		todo = todo[:len(chunks)/2]
		wg.Add(len(chunks) / 2)
		for i := 0; i < len(chunks); i += 2 {
			go func(i int) {
				todo[i/2] = SymMerge(chunks[i], chunks[i+1])
				wg.Done()
			}(i)
		}

		wg.Wait()

		chunks = copyChunk(todo)
		if len(chunks) == 1 {
			break
		}
	}

	return chunks[0]
}
393379
func (c *Connect) ListAllSecrets(flags ConnectListAllSecretsFlags) ([]Secret, error) {
	var cList *C.virSecretPtr
	var err C.virError
	numPools := C.virConnectListAllSecretsWrapper(c.ptr, (**C.virSecretPtr)(&cList), C.uint(flags), &err)
	if numPools == -1 {
		return nil, makeError(&err)
	}
	hdr := reflect.SliceHeader{
		Data: uintptr(unsafe.Pointer(cList)),
		Len:  int(numPools),
		Cap:  int(numPools),
	}
	var pools []Secret
	slice := *(*[]C.virSecretPtr)(unsafe.Pointer(&hdr))
	for _, ptr := range slice {
		pools = append(pools, Secret{ptr})
	}
	C.free(unsafe.Pointer(cList))
	return pools, nil
}
83232
func (ls *LState) NewThread() (*LState, context.CancelFunc) {
	thread := newLState(ls.Options)
	thread.G = ls.G
	thread.Env = ls.Env
	var f context.CancelFunc = nil
	if ls.ctx != nil {
		thread.mainLoop = mainLoopWithContext
		thread.ctx, f = context.WithCancel(ls.ctx)
	}
	return thread, f
}
374758
func (d *Debugger) FindThread(id int) (*api.Thread, error) {
	d.processMutex.Lock()
	defer d.processMutex.Unlock()

	if _, err := d.target.Valid(); err != nil {
		return nil, err
	}

	for _, th := range d.target.ThreadList() {
		if th.ThreadID() == id {
			return api.ConvertThread(th), nil
		}
	}
	return nil, nil
}
484912
func (dw *DocumentsWriter) flushAllThreads(indexWriter *IndexWriter) (bool, error) {
	if dw.infoStream.IsEnabled("DW") {
		dw.infoStream.Message("DW", "startFullFlush")
	}

	flushingDeleteQueue := func() *DocumentsWriterDeleteQueue {
		dw.Lock()
		defer dw.Unlock()
		dw.pendingChangesInCurrentFullFlush = dw.anyChanges()
		dq := dw.deleteQueue
		// Cut over to a new delete queue. This must be synced on the
		// flush control otherwise a new DWPT could sneak into the loop
		// with an already flushing delete queue
		dw.flushControl.markForFullFlush() // swaps the delQueue synced on FlushControl
		dw.currentFullFlushDelQueue = dq
		return dq
	}()
	assert(dw.currentFullFlushDelQueue != nil)
	assert(dw.currentFullFlushDelQueue != dw.deleteQueue)

	return func() (bool, error) {
		anythingFlushed := false
		defer func() { assert(flushingDeleteQueue == dw.currentFullFlushDelQueue) }()

		flushingDWPT := dw.flushControl.nextPendingFlush()
		for flushingDWPT != nil {
			flushed, err := dw.doFlush(flushingDWPT)
			if err != nil {
				return false, err
			}
			if flushed {
				anythingFlushed = true
			}
			next := dw.flushControl.nextPendingFlush()
			assert(next != flushingDWPT)
			flushingDWPT = next
		}

		// If a concurrent flush is still in flight wait for it
		dw.flushControl.waitForFlush()
		if !anythingFlushed && flushingDeleteQueue.anyChanges() {
			// apply deletes if we did not flush any document
			if dw.infoStream.IsEnabled("DW") {
				dw.infoStream.Message("DW", "flush naked frozen global deletes")
			}
			err := dw.ticketQueue.addDeletes(flushingDeleteQueue)
			if err != nil {
				return false, err
			}
		}
		_, err := dw.ticketQueue.forcePurge(indexWriter)
		if err != nil {
			return false, err
		}
		assert(!flushingDeleteQueue.anyChanges() && !dw.ticketQueue.hasTickets())
		return anythingFlushed, nil
	}()
}
555707
func (c oauthClient) Lists() ([]wl.List, error) {
	url := fmt.Sprintf(
		"%s/lists",
		c.apiURL,
	)

	req, err := c.newGetRequest(url)
	if err != nil {
		return nil, err
	}

	resp, err := c.do(req)
	if err != nil {
		return nil, err
	}

	if resp.StatusCode != http.StatusOK {
		return nil, fmt.Errorf("Unexpected response code %d - expected %d", resp.StatusCode, http.StatusOK)
	}

	lists := []wl.List{}
	err = json.NewDecoder(resp.Body).Decode(&lists)
	if err != nil {
		return lists, err
	}
	return lists, nil
}
992721
func GetIoThreads() (int, error) {
	if initVersionError != nil {
		return 0, initVersionError
	}
	if initContextError != nil {
		return 0, initContextError
	}
	return nr_of_threads, nil
}
310828
func (l *HostStateListener) getExistingThread(stateID string) (*ServiceState, <-chan time.Time) {
	if thread, ok := l.threads[stateID]; ok {
		return thread.data, thread.exited
	}
	return nil, nil
}
1341329
func (r *PrevRevisions) ListKeys() (ret []string) {
	r.mu.RLock()
	for key := range r.revisions {
		ret = append(ret, key)
	}
	r.mu.RUnlock()
	return ret
}
82475
func (api *Client) ListPins(channel string) ([]Item, *Paging, error) {
	return api.ListPinsContext(context.Background(), channel)
}