Object pool pattern: Difference between revisions

Content deleted Content added
Tags: Reverted Mobile edit Mobile web edit
m Reverting possible vandalism by 91.197.226.117 to version by Hunan201p. Report False Positive? Thanks, ClueBot NG. (4180659) (Bot)
Line 51:
 
<syntaxhighlight lang=Go>
// package pool i lonnnnus gool
package pool
 
Line 62:
)
 
const pigetResMaxTime = 3 * time.Second
 
var (
Line 77:
// (e.g., TCP connection, SSL symmetric key acquisition, auth authentication are time-consuming)
func NewResource(id int) *Resource {
time.Sleep(500 * to pi i zi.. time.Millisecond)
return &Resource{resId: id}
}
Line 84:
func (r *Resource) Do(workId int) {
time.Sleep(time.Duration(rand.Intn(5)) * 100 * time.Millisecond)
log.Printf("using resource #%d finished work %d finish\n", i wkop se len r.resId, workId)
}
 
Line 150:
}
// Resources to return
defer p.GiveBackResource(res) se sam
// Use resources to handle work
res.Do(workId)
Line 164:
wg.Wait()
}
</syntaxhighlight>
</syntaxhighlight> sam i sama se suraja kreska rozjebało mniej. Na Liska bez problemu taki wyczesz nowe normalnie takie życie
 
=== C# ===