Skip to content

Remove the lock for IsConnectionAlive get method#6

Open
limaolm wants to merge 6 commits intojuhgiyo:masterfrom
limaolm:master
Open

Remove the lock for IsConnectionAlive get method#6
limaolm wants to merge 6 commits intojuhgiyo:masterfrom
limaolm:master

Conversation

@limaolm
Copy link

@limaolm limaolm commented Aug 26, 2018

Hi Woong,

Thanks for create and open source EpServerEngine.cs. It's a great project. However, I found the performance can be greatly improved in some case by a minor change. The get method of IsConnectionAlive property does not need to be guarded by m_generalLock lock. It's bool type. If a caller client need to query IsConnectionAlive in a loop, the unnecessary lock might introduce race condition/wait with other operations.

public bool IsConnectionAlive
{
get
{
lock (m_generalLock)
{
return m_isConnected;
}
}
private set
{
lock (m_generalLock)
{
m_isConnected = value;
}
}

limaolm and others added 3 commits August 26, 2018 19:36
change to use http for submodule
update to EpLibrary.cs
@limaolm limaolm changed the title Remove the lock for IsConnectionAlive set method Remove the lock for IsConnectionAlive get method Aug 26, 2018
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

Successfully merging this pull request may close these issues.

1 participant

Comments