mirror of
				https://github.com/HDT3213/godis.git
				synced 2025-10-31 12:06:26 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			23 lines
		
	
	
		
			396 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			396 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package pubsub
 | |
| 
 | |
| import (
 | |
| 	"github.com/hdt3213/godis/datastruct/dict"
 | |
| 	"github.com/hdt3213/godis/datastruct/lock"
 | |
| )
 | |
| 
 | |
| // Hub stores all subscribe relations
 | |
| type Hub struct {
 | |
| 	// channel -> list(*Client)
 | |
| 	subs dict.Dict
 | |
| 	// lock channel
 | |
| 	subsLocker *lock.Locks
 | |
| }
 | |
| 
 | |
| // MakeHub creates new hub
 | |
| func MakeHub() *Hub {
 | |
| 	return &Hub{
 | |
| 		subs:       dict.MakeConcurrent(4),
 | |
| 		subsLocker: lock.Make(16),
 | |
| 	}
 | |
| }
 | 
