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, }) }
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, }) }