]> Cypherpunks repositories - gostls13.git/commitdiff
delete pkg/once
authorRob Pike <r@golang.org>
Fri, 13 Aug 2010 02:53:27 +0000 (12:53 +1000)
committerRob Pike <r@golang.org>
Fri, 13 Aug 2010 02:53:27 +0000 (12:53 +1000)
R=rsc
CC=golang-dev
https://golang.org/cl/1995041

src/pkg/Makefile
src/pkg/once/Makefile [deleted file]
src/pkg/once/once.go [deleted file]
src/pkg/once/once_test.go [deleted file]
test/garbage/parser.go

index 7d135962f19fae28542e02c6b93566517163d440..5c4bbadb10b427371bb183a16a1edc77cd95ca96 100644 (file)
@@ -100,7 +100,6 @@ DIRS=\
        net/textproto\
        netchan\
        nntp\
-       once\
        os\
        os/signal\
        patch\
diff --git a/src/pkg/once/Makefile b/src/pkg/once/Makefile
deleted file mode 100644 (file)
index e87fbf8..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-include ../../Make.$(GOARCH)
-
-TARG=once
-GOFILES=\
-       once.go\
-
-include ../../Make.pkg
diff --git a/src/pkg/once/once.go b/src/pkg/once/once.go
deleted file mode 100644 (file)
index 43949ee..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// This package provides a single function, Do, to run a function
-// exactly once, usually used as part of initialization.
-package once
-
-import "sync"
-
-type job struct {
-       done       bool
-       sync.Mutex // should probably be sync.Notification or some such
-}
-
-var jobs = make(map[func()]*job)
-var joblock sync.Mutex
-
-// Do is the the only exported piece of the package.
-// For one-time initialization that is not done during init,
-// wrap the initialization in a niladic function f() and call
-//     Do(f)
-// If multiple processes call Do(f) simultaneously
-// with the same f argument, only one will call f, and the
-// others will block until f finishes running.
-//
-// Since a func() expression typically evaluates to a differerent
-// function value each time it is evaluated, it is incorrect to
-// pass such values to Do.  For example,
-//     func f(x int) {
-//             Do(func() { fmt.Println(x) })
-//     }
-// behaves the same as
-//     func f(x int) {
-//             fmt.Println(x)
-//     }
-// because the func() expression in the first creates a new
-// func each time f runs, and each of those funcs is run once.
-func Do(f func()) {
-       joblock.Lock()
-       j := jobs[f]
-       if j == nil {
-               // run it
-               j = new(job)
-               j.Lock()
-               jobs[f] = j
-               joblock.Unlock()
-               f()
-               j.done = true
-               j.Unlock()
-       } else {
-               // wait for it
-               joblock.Unlock()
-               if j.done != true {
-                       j.Lock()
-                       j.Unlock()
-               }
-       }
-}
diff --git a/src/pkg/once/once_test.go b/src/pkg/once/once_test.go
deleted file mode 100644 (file)
index e7aaec3..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2009 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package once_test
-
-import (
-       "once"
-       "testing"
-)
-
-var ncall int
-
-func call() { ncall++ }
-
-func TestDo(t *testing.T) {
-       ncall = 0
-       once.Do(call)
-       if ncall != 1 {
-               t.Fatalf("once.Do(call) didn't call(): ncall=%d", ncall)
-       }
-       once.Do(call)
-       if ncall != 1 {
-               t.Fatalf("second once.Do(call) did call(): ncall=%d", ncall)
-       }
-       once.Do(call)
-       if ncall != 1 {
-               t.Fatalf("third once.Do(call) did call(): ncall=%d", ncall)
-       }
-}
index e8e049474c122ade138ebccda555b49926998e21..a0fd19a621f5ff422128bc9ac500bc2813adfc5a 100644 (file)
@@ -185,7 +185,6 @@ var packages = []string{
        "mime",
        "net",
        "nntp",
-       "once",
        "os",
        "os/signal",
        "patch",