當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Process.Go方法代碼示例

本文整理匯總了Golang中github.com/djbarber/ipfs-hack/Godeps/_workspace/src/github.com/jbenet/goprocess.Process.Go方法的典型用法代碼示例。如果您正苦於以下問題:Golang Process.Go方法的具體用法?Golang Process.Go怎麽用?Golang Process.Go使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/djbarber/ipfs-hack/Godeps/_workspace/src/github.com/jbenet/goprocess.Process的用法示例。


在下文中一共展示了Process.Go方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: startWorkers

func (bs *Bitswap) startWorkers(px process.Process, ctx context.Context) {
	// Start up a worker to handle block requests this node is making
	px.Go(func(px process.Process) {
		bs.providerConnector(ctx)
	})

	// Start up workers to handle requests from other nodes for the data on this node
	for i := 0; i < TaskWorkerCount; i++ {
		i := i
		px.Go(func(px process.Process) {
			bs.taskWorker(ctx, i)
		})
	}

	// Start up a worker to manage periodically resending our wantlist out to peers
	px.Go(func(px process.Process) {
		bs.rebroadcastWorker(ctx)
	})

	// Start up a worker to manage sending out provides messages
	px.Go(func(px process.Process) {
		bs.provideCollector(ctx)
	})

	// Spawn up multiple workers to handle incoming blocks
	// consider increasing number if providing blocks bottlenecks
	// file transfers
	px.Go(bs.provideWorker)
}
開發者ID:djbarber,項目名稱:ipfs-hack,代碼行數:29,代碼來源:workers.go

示例2: spawnWorkers

func (r *dhtQueryRunner) spawnWorkers(proc process.Process) {
	for {

		select {
		case <-r.peersRemaining.Done():
			return

		case <-r.proc.Closing():
			return

		case p, more := <-r.peersToQuery.DeqChan:
			if !more {
				return // channel closed.
			}

			// do it as a child func to make sure Run exits
			// ONLY AFTER spawn workers has exited.
			proc.Go(func(proc process.Process) {
				r.queryPeer(proc, p)
			})
		}
	}
}
開發者ID:djbarber,項目名稱:ipfs-hack,代碼行數:23,代碼來源:query.go


注:本文中的github.com/djbarber/ipfs-hack/Godeps/_workspace/src/github.com/jbenet/goprocess.Process.Go方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。