-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it harder to cause a race condition to begin with
Instead of returning a struct with mutable struct, we can make it harder to cause a race condition by wrapping all of that state instead of a function closure which cannot be modified from the outside, and by using sync.Once() to ensure that only one request is ever handled. We only need to have the sync.Once() for close()ing the channel to permit a user to permit a user to free the resources manually. It is still possible to cause a panic by closing this channel before receiving a request.
- Loading branch information
1 parent
6000b9d
commit 23d2af4
Showing
2 changed files
with
119 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters