(userID string)
| 128 | } |
| 129 | |
| 130 | func NewUserSemaphoreManager() *UserSemaphoreManager { |
| 131 | return &UserSemaphoreManager{} |
| 132 | } |
| 133 | |
| 134 | func (usm *UserSemaphoreManager) ForUser(userID string) chan struct{} { |
| 135 | // LoadOrStore provides an atomic way to get or create a semaphore. |
| 136 | pool, _ := usm.pools.LoadOrStore(userID, make(chan struct{}, openGraphUserFetchLimit)) |
| 137 | return pool.(chan struct{}) |