Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql_connect_pool.cpp中的GetConnection函数的一个问题? #269

Open
PPhoss opened this issue Mar 27, 2024 · 0 comments
Open

sql_connect_pool.cpp中的GetConnection函数的一个问题? #269

PPhoss opened this issue Mar 27, 2024 · 0 comments

Comments

@PPhoss
Copy link

PPhoss commented Mar 27, 2024

MYSQL *connection_pool::GetConnection()
{
	MYSQL *con = NULL;

	if (0 == connList.size())
		return NULL;

	reserve.wait();
	
	lock.lock();

	con = connList.front();
	connList.pop_front();

	--m_FreeConn;
	++m_CurConn;

	lock.unlock();
	return con;
}

大佬们,我想问一下,这个函数中为什么要做if(0==connList.size())这个判断?如果做了这个判断不久直接返回了吗,就不会有后面的reserve.wait()等待了呀?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant