forked from lunny/godbc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.go
More file actions
33 lines (29 loc) · 678 Bytes
/
stats.go
File metadata and controls
33 lines (29 loc) · 678 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2012 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 odbc
import (
"fmt"
"github.com/lunny/godbc/api"
"sync"
)
type Stats struct {
EnvCount int
ConnCount int
StmtCount int
mu sync.Mutex
}
func (s *Stats) updateHandleCount(handleType api.SQLSMALLINT, change int) {
s.mu.Lock()
defer s.mu.Unlock()
switch handleType {
case api.SQL_HANDLE_ENV:
s.EnvCount += change
case api.SQL_HANDLE_DBC:
s.ConnCount += change
case api.SQL_HANDLE_STMT:
s.StmtCount += change
default:
panic(fmt.Errorf("unexpected handle type %d", handleType))
}
}