func (cm *PubSub) Subscribe(id string, subscriber Subscriber) {
	if id == "" || subscriber == nil {
		return
	}
	cm.lock.Lock()
	defer cm.lock.Unlock()

	subscribers, ok := cm.subMap[id]
	if !ok {
		subscribers = subscriberSet{}
		cm.subMap[id] = subscribers
	}

	ids, ok := cm.idMap[subscriber]
	if !ok {
		ids = util.NewStringSet()
		cm.idMap[subscriber] = ids
	}

	subscribers[subscriber] = struct{}{}
	ids.Add(id)
}
// Subscribe - subscribes a Subscriber to an id
subscribes a Subscriber to an id
// Subscribe - subscribes a Subscriber to an id
func (cm *PubSub) Subscribe(id string, subscriber Subscriber) {
	if id == "" || subscriber == nil {
		return
	}
	cm.lock.Lock()
	defer cm.lock.Unlock()
	subscribers, ok := cm.subMap[id]
	if !ok {
		subscribers = subscriberSet{}
		cm.subMap[id] = subscribers
	}
	ids, ok := cm.idMap[subscriber]
	if !ok {
		ids = util.NewStringSet()
		cm.idMap[subscriber] = ids
	}
	subscribers[subscriber] = struct{}{}
	ids.Add(id)
}
func ( cm * PubSub ) Subscribe ( id string , subscriber Subscriber ) { if id == " " || subscriber == nil { return } cm . lock . Lock ( ) defer cm . lock . Unlock ( ) subscribers , ok := cm . subMap [ id ] if ! ok { subscribers = subscriberSet { } cm . subMap [ id ] = subscribers } ids , ok := cm . idMap [ subscriber ] if ! ok { ids = util . NewStringSet ( ) cm . idMap [ subscriber ] = ids } subscribers [ subscriber ] = struct { } { } ids . Add ( id ) }
subscribes a Subscriber to an id
subscribes a Subscriber to an id