Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine pooled EntryOptions management #277

Merged
merged 1 commit into from
Oct 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ func WithAttachments(data map[interface{}]interface{}) EntryOption {
// Entry is the basic API of Sentinel.
func Entry(resource string, opts ...EntryOption) (*base.SentinelEntry, *base.BlockError) {
options := entryOptsPool.Get().(*EntryOptions)
defer func() {
options.Reset()
entryOptsPool.Put(options)
}()

options.slotChain = globalSlotChain

for _, opt := range opts {
Expand Down Expand Up @@ -145,8 +150,6 @@ func entry(resource string, options *EntryOptions) (*base.SentinelEntry, *base.B
if len(options.attachments) != 0 {
ctx.Input.Attachments = options.attachments
}
options.Reset()
entryOptsPool.Put(options)
e := base.NewSentinelEntry(ctx, rw, sc)
ctx.SetEntry(e)
r := sc.Entry(ctx)
Expand Down