aboutsummaryrefslogtreecommitdiff
path: root/middleware/pkg/singleflight/singleflight.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-09-14 09:36:06 +0100
committerGravatar GitHub <noreply@github.com> 2017-09-14 09:36:06 +0100
commitd8714e64e400ef873c2adc4d929a07d7890727b9 (patch)
treec9fa4c157e6af12eb1517654f8d23ca5d5619513 /middleware/pkg/singleflight/singleflight.go
parentb984aa45595dc95253b91191afe7d3ee29e71b48 (diff)
downloadcoredns-d8714e64e400ef873c2adc4d929a07d7890727b9.tar.gz
coredns-d8714e64e400ef873c2adc4d929a07d7890727b9.tar.zst
coredns-d8714e64e400ef873c2adc4d929a07d7890727b9.zip
Remove the word middleware (#1067)
* Rename middleware to plugin first pass; mostly used 'sed', few spots where I manually changed text. This still builds a coredns binary. * fmt error * Rename AddMiddleware to AddPlugin * Readd AddMiddleware to remain backwards compat
Diffstat (limited to 'middleware/pkg/singleflight/singleflight.go')
-rw-r--r--middleware/pkg/singleflight/singleflight.go64
1 files changed, 0 insertions, 64 deletions
diff --git a/middleware/pkg/singleflight/singleflight.go b/middleware/pkg/singleflight/singleflight.go
deleted file mode 100644
index 365e3ef58..000000000
--- a/middleware/pkg/singleflight/singleflight.go
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-Copyright 2012 Google Inc.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Package singleflight provides a duplicate function call suppression
-// mechanism.
-package singleflight
-
-import "sync"
-
-// call is an in-flight or completed Do call
-type call struct {
- wg sync.WaitGroup
- val interface{}
- err error
-}
-
-// Group represents a class of work and forms a namespace in which
-// units of work can be executed with duplicate suppression.
-type Group struct {
- mu sync.Mutex // protects m
- m map[uint32]*call // lazily initialized
-}
-
-// Do executes and returns the results of the given function, making
-// sure that only one execution is in-flight for a given key at a
-// time. If a duplicate comes in, the duplicate caller waits for the
-// original to complete and receives the same results.
-func (g *Group) Do(key uint32, fn func() (interface{}, error)) (interface{}, error) {
- g.mu.Lock()
- if g.m == nil {
- g.m = make(map[uint32]*call)
- }
- if c, ok := g.m[key]; ok {
- g.mu.Unlock()
- c.wg.Wait()
- return c.val, c.err
- }
- c := new(call)
- c.wg.Add(1)
- g.m[key] = c
- g.mu.Unlock()
-
- c.val, c.err = fn()
- c.wg.Done()
-
- g.mu.Lock()
- delete(g.m, key)
- g.mu.Unlock()
-
- return c.val, c.err
-}
class='tabs'> aboutsummaryrefslogtreecommitdiff
path: root/src/http.zig (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2023-01-05BumpGravatar Jarred Sumner 1-1/+1
2023-01-05fix `onConnectError()` error propagation (#1730)Gravatar Alex Lam S.L 1-2/+2
2023-01-05Update tcp-echo.bun.tsGravatar Jarred Sumner 1-13/+15
2023-01-05Really fix #1722Gravatar Jarred Sumner 2-3/+41
2023-01-05improve `.toThrow()` compatibility with Jest (#1728)Gravatar Alex Lam S.L 2-17/+33
2023-01-04Fix Bun.serve typings (#1714)Gravatar u9g 1-2/+2
2023-01-04implement `expect().toThrow()` (#1727)Gravatar Alex Lam S.L 5-130/+370
2023-01-04Add `SharedBuffer` from WebKit to make it easier to import more WebCore stuffGravatar Jarred Sumner 2-0/+1111
2023-01-04Fix default export for streamGravatar Jarred Sumner 1-11/+4
2023-01-04Fixes #1722Gravatar Jarred Sumner 1-1/+2
2023-01-04split server/client for tcp echo benchmark to better measure net.Socket perfGravatar Jarred Sumner 2-58/+60
2023-01-04buffer list clean-ups (#1721)Gravatar Alex Lam S.L 1-37/+68
2023-01-04Support non-classes in node:net (#1712)Gravatar Jarred Sumner 1-198/+216
2023-01-04Fixes #1716Gravatar Jarred Sumner 1-2/+2
2023-01-0410x faster `new Buffer` (#1717)Gravatar Jarred Sumner 19-520/+480
2023-01-03Update README.mdGravatar Jarred Sumner 1-2/+2
2023-01-03Add sqlite to vendorGravatar Jarred Sumner 1-4/+8
2023-01-03Fixes https://github.com/oven-sh/bun/issues/1695Gravatar Jarred Sumner 1-1/+1
2023-01-03Remove usages of std.xGravatar Jarred Sumner 7-98/+75
2023-01-03[streams] speed up `Readable` in some cases (#1708)Gravatar Alex Lam S.L 3-14/+140
2023-01-03Fix crash in BufferListGravatar Jarred Sumner 1-2/+2