Пример #1
0
func (hf *HandleFactory) NewHandle(call testcapnp.HandleFactory_newHandle) error {
	server.Ack(call.Options)
	if hf.singleton.Client == nil {
		hf.mu.Lock()
		hf.n++
		hf.mu.Unlock()
		call.Results.SetHandle(testcapnp.Handle_ServerToClient(&Handle{f: hf}))
	} else {
		hf.mu.Lock()
		hf.n = 1
		hf.mu.Unlock()
		call.Results.SetHandle(hf.singleton)
	}
	return nil
}
Пример #2
0
func singletonHandleFactory() *HandleFactory {
	hf := new(HandleFactory)
	hf.singleton = testcapnp.Handle_ServerToClient(&Handle{f: hf})
	return hf
}