- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 3,435 for defer3 (0.28 sec)
-
src/runtime/runtime_test.go
for i := 0; i < b.N; i++ { defer1() } } func defer1() { defer func(x, y, z int) { if recover() != nil || x != 1 || y != 2 || z != 3 { panic("bad recover") } }(1, 2, 3) } func BenchmarkDefer10(b *testing.B) { for i := 0; i < b.N/10; i++ { defer2() } } func defer2() { for i := 0; i < 10; i++ { defer func(x, y, z int) {
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu May 23 01:00:11 UTC 2024 - 11.7K bytes - Viewed (0) -
src/cmd/vendor/golang.org/x/tools/go/analysis/passes/defers/defers.go
Requires: []*analysis.Analyzer{inspect.Analyzer}, URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/defers", Doc: analysisutil.MustExtractDoc(doc, "defers"), Run: run, } func run(pass *analysis.Pass) (interface{}, error) { if !analysisutil.Imports(pass.Pkg, "time") { return nil, nil } checkDeferCall := func(node ast.Node) bool { switch v := node.(type) { case *ast.CallExpr:
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu Oct 19 23:33:33 UTC 2023 - 1.4K bytes - Viewed (0) -
test/defer.go
// license that can be found in the LICENSE file. // Test defer. package main import "fmt" var result string func addInt(i int) { result += fmt.Sprint(i) } func test1helper() { for i := 0; i < 10; i++ { defer addInt(i) } } func test1() { result = "" test1helper() if result != "9876543210" { fmt.Printf("test1: bad defer result (should be 9876543210): %q\n", result) panic("defer")
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue Feb 12 18:17:49 UTC 2013 - 875 bytes - Viewed (0) -
test/defererrcheck.go
func f2() { for { defer func() { // ERROR "heap-allocated defer" fmt.Println("defer1") }() if glob > 2 { break } } defer func() { // ERROR "stack-allocated defer" fmt.Println("defer2") }() } func f3() { defer func() { // ERROR "stack-allocated defer" fmt.Println("defer2") }() for { defer func() { // ERROR "heap-allocated defer" fmt.Println("defer1") }() if glob > 2 {
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Wed Feb 26 16:54:17 UTC 2020 - 1.4K bytes - Viewed (0) -
src/runtime/panic.go
) // We have two different ways of doing defers. The older way involves creating a // defer record at the time that a defer statement is executing and adding it to a // defer chain. This chain is inspected by the deferreturn call at all function // exits in order to run the appropriate defer calls. A cheaper way (which we call // open-coded defers) is used for functions in which no defer statements occur in
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Wed May 29 17:58:53 UTC 2024 - 43.8K bytes - Viewed (0) -
src/cmd/vendor/golang.org/x/tools/go/analysis/passes/defers/doc.go
// Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package defers defines an Analyzer that checks for common mistakes in defer // statements. // // # Analyzer defers // // defers: report common mistakes in defer statements // // The defers analyzer reports a diagnostic when a defer statement would // result in a non-deferred call to time.Since, as experience has shown
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Mon Sep 25 20:06:48 UTC 2023 - 763 bytes - Viewed (0) -
src/runtime/stack_test.go
func deferHeapAndStack(n int) (r int) { if n == 0 { return 0 } if n%2 == 0 { // heap-allocated defers for i := 0; i < 2; i++ { defer func() { r++ }() } } else { // stack-allocated defers defer func() { r++ }() defer func() { r++ }() } r = deferHeapAndStack(n - 1) escapeMe(new([1024]byte)) // force some GCs return }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Wed Jun 14 00:03:57 UTC 2023 - 23.1K bytes - Viewed (0) -
src/runtime/defer_test.go
defer step(t, &steps, 9) step(t, &steps, 8) }() func() { defer step(t, &steps, 13) defer step(t, &steps, 12) func() { defer step(t, &steps, 11) panic(4) }() // Code below isn't executed, // but removing it breaks the test case. defer func() {}() defer panic(-1) defer step(t, &steps, -1) defer step(t, &steps, -1) defer func() {}() }()
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Wed Sep 20 18:57:24 UTC 2023 - 11.4K bytes - Viewed (0) -
test/fixedbugs/issue8048.go
// The runtime should see that there are no defers // corresponding to this panicked frame and ignore // the frame entirely. var x *int var b bool if b { y := make([]int, 1) runtime.GC() x = &y[0] } println(*x) } func test2() { // Same as test1, but the fault happens in the function with the defer. // The runtime should see the defer and garbage collect the frame
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Mon May 02 13:43:18 UTC 2016 - 2K bytes - Viewed (0) -
test/deferfin.go
wg.Add(N) for i := 0; i < N; i++ { go func() { defer wg.Done() v := new(string) f := func() { if *v != "" { panic("oops") } } if *v != "" { // let the compiler think f escapes sink = f } runtime.SetFinalizer(v, func(p *string) { atomic.AddInt32(&count, -1) }) defer f() }() } wg.Wait() for i := 0; i < 3; i++ {
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue Jan 05 21:11:31 UTC 2021 - 1.1K bytes - Viewed (0)