示例#1
0
文件: slave.go 项目: zond/hackyhack
func (s *slaveDriver) destruct(d *messages.Deconstruct) {
	s.slaveLock.Lock()
	slave, found := s.slaves[d.Resource]
	if found {
		if destructible, ok := slave.(interfaces.Destructible); ok {
			go destructible.Destroy()
		}
		d.Deconstructed = true
	}
	delete(s.slaves, d.Resource)
	s.slaveLock.Unlock()

	s.flyingRequestsLock.Lock()
	for requestId, flying := range s.flyingRequests {
		if flying.resource == d.Resource {
			delete(s.flyingRequests, requestId)
		}
	}
	s.flyingRequestsLock.Unlock()

	s.emit(&messages.Blob{
		Type:     messages.BlobTypeDestruct,
		Destruct: d,
	})
}
示例#2
0
文件: slave.go 项目: zond/hackyhack
func (s *slaveDriver) construct(c *messages.Deconstruct) {
	s.slaveLock.Lock()
	_, found := s.slaves[c.Resource]
	if !found {
		s.slaves[c.Resource] = s.generator(&mcp{
			driver:   s,
			resource: c.Resource,
		})
		c.Deconstructed = true
	}
	s.slaveLock.Unlock()

	s.emit(&messages.Blob{
		Type:      messages.BlobTypeConstruct,
		Construct: c,
	})
}