-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [WIN-NPM] parallelize HNS SetPolicy calls
Signed-off-by: Hunter Gregory <42728408+huntergregory@users.noreply.github.com>
- Loading branch information
1 parent
ae690d2
commit 15205ad
Showing
7 changed files
with
173 additions
and
8 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package ipsets | ||
|
||
type workerPool struct{} | ||
|
||
func newWorkerPool() *workerPool { | ||
return &workerPool{} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package ipsets | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/Microsoft/hcsshim/hcn" | ||
) | ||
|
||
const maxThreads = 10 | ||
|
||
type thread struct { | ||
id int | ||
op hcn.RequestType | ||
wg *sync.WaitGroup | ||
ipsets map[string]*hcn.SetPolicySetting | ||
} | ||
|
||
type workerPool struct { | ||
sync.Mutex | ||
semaphore chan struct{} | ||
threads map[int]*thread | ||
} | ||
|
||
func newWorkerPool() *workerPool { | ||
return &workerPool{ | ||
semaphore: make(chan struct{}, maxThreads), | ||
threads: make(map[int]*thread), | ||
} | ||
} |