<commit_before>package xorm

import (
	"database/sql"
	"fmt"
	//"sync"
	"sync/atomic"
	//"time"
)

type IConnectionPool interface {
	RetrieveDB(engine *Engine) (*sql.DB, error)
	ReleaseDB(engine *Engine, db *sql.DB)
}

type NoneConnectPool struct {
}

var ConnectionNum int32 = 0

func (p NoneConnectPool) RetrieveDB(engine *Engine) (db *sql.DB, err error) {
	atomic.AddInt32(&ConnectionNum, 1)
	db, err = engine.OpenDB()
	fmt.Printf("--open a connection--%x\n", &db)
	return
}

func (p NoneConnectPool) ReleaseDB(engine *Engine, db *sql.DB) {
	atomic.AddInt32(&ConnectionNum, -1)
	fmt.Printf("--close a connection--%x\n", &db)
	db.Close()
}

/*type SimpleConnectPool struct {
	releasedSessions []*sql.DB
	cur              int
	usingSessions    map[*sql.DB]time.Time
	maxWaitTimeOut   int
	mutex            *sync.Mutex
}

func (p SimpleConnectPool) RetrieveDB(engine *Engine) (*sql.DB, error) {
	p.mutex.Lock()
	defer p.mutex.Unlock()
	var db *sql.DB = nil
	var err error = nil
	fmt.Printf("%x, rbegin - released:%v, using:%v\n", &p, p.cur+1, len(p.usingSessions))
	if p.cur < 0 {
		ConnectionNum = ConnectionNum + 1<commit_msg>fix bug<commit_after>package xorm

import (
	"database/sql"
	"fmt"
	//"sync"
	"sync/atomic"
	//"time"
)

type IConnectionPool interface {
	RetrieveDB(engine *Engine) (*sql.DB, error)
	ReleaseDB(engine *Engine, db *sql.DB)
}

type NoneConnectPool struct {
}

var ConnectionNum int32 = 0

func (p NoneConnectPool) RetrieveDB(engine *Engine) (db *sql.DB, err error) {
	atomic.AddInt32(&ConnectionNum, 1)
	db, err = engine.OpenDB()
	//fmt.Printf("--open a connection--%x\n", &db)
	return
}

func (p NoneConnectPool) ReleaseDB(engine *Engine, db *sql.DB) {
	atomic.AddInt32(&ConnectionNum, -1)
	//fmt.Printf("--close a connection--%x\n", &db)
	db.Close()
}

/*type SimpleConnectPool struct {
	releasedSessions []*sql.DB
	cur              int
	usingSessions    map[*sql.DB]time.Time
	maxWaitTimeOut   int
	mutex            *sync.Mutex
}

func (p SimpleConnectPool) RetrieveDB(engine *Engine) (*sql.DB, error) {
	p.mutex.Lock()
	defer p.mutex.Unlock()
	var db *sql.DB = nil
	var err error = nil
	fmt.Printf("%x, rbegin - released:%v, using:%v\n", &p, p.cur+1, len(p.usingSessions))
	if p.cur < 0 {
		ConnectionNum = ConnectionNum + 1
{'fraction_non_alphanumeric': 0.15527950310559005, 'fraction_numerical': 0.01064773735581189, 'mean_word_length': 3.797872340425532, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6896388', 'n_tokens_mistral': 866, 'n_tokens_neox': 853, 'n_words': 206}