Improve thread safety.

This commit is contained in:
lotodore
2011-01-12 23:35:45 +00:00
parent b6c820718a
commit 2a7456998a
10 changed files with 51 additions and 39 deletions
+6 -4
View File
@@ -103,6 +103,7 @@ ClientBeRo::setSmallBlindPositionId(unsigned theValue)
unsigned
ClientBeRo::getSmallBlindPositionId() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return smallBlindPositionId;
}
@@ -116,6 +117,7 @@ ClientBeRo::setBigBlindPositionId(unsigned theValue)
unsigned
ClientBeRo::getBigBlindPositionId() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return bigBlindPositionId;
}
@@ -220,15 +222,15 @@ ClientBeRo::getMinimumRaise() const
void
ClientBeRo::setFullBetRule ( bool theValue )
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
fullBetRule = theValue;
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
fullBetRule = theValue;
}
bool
ClientBeRo::getFullBetRule() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return fullBetRule;
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return fullBetRule;
}
void
+1 -8
View File
@@ -24,7 +24,7 @@
using namespace std;
ClientBoard::ClientBoard(unsigned dp)
: currentHand(0), pot(0), sets(0), dealerPosition(dp)
: pot(0), sets(0), dealerPosition(dp)
{
myCards[0] = myCards[1] = myCards[2] = myCards[3] = myCards[4] = 0;
}
@@ -43,13 +43,6 @@ ClientBoard::setPlayerLists(PlayerList sl, PlayerList apl, PlayerList rpl)
runningPlayerList = rpl;
}
void
ClientBoard::setHand(HandInterface* br)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
currentHand = br;
}
void
ClientBoard::setMyCards(int* theValue)
{
+4 -7
View File
@@ -35,7 +35,6 @@ public:
~ClientBoard();
void setPlayerLists(PlayerList, PlayerList, PlayerList);
void setHand(HandInterface*);
void setMyCards(int* theValue);
void getMyCards(int* theValue);
@@ -52,13 +51,13 @@ public:
void collectPot();
void distributePot();
void determinePlayerNeedToShowCards();
void determinePlayerNeedToShowCards();
std::list<unsigned> getWinners() const;
void setWinners(const std::list<unsigned> &winners);
std::list<unsigned> getPlayerNeedToShowCards() const;
void setPlayerNeedToShowCards(const std::list<unsigned> &playerNeedToShowCards);
std::list<unsigned> getPlayerNeedToShowCards() const;
void setPlayerNeedToShowCards(const std::list<unsigned> &playerNeedToShowCards);
private:
mutable boost::recursive_mutex m_syncMutex;
@@ -67,10 +66,8 @@ private:
PlayerList activePlayerList;
PlayerList runningPlayerList;
HandInterface *currentHand;
std::list<unsigned> winners;
std::list<unsigned> playerNeedToShowCards;
std::list<unsigned> playerNeedToShowCards;
int myCards[5];
int pot;
+10 -2
View File
@@ -68,24 +68,28 @@ ClientHand::start()
PlayerList
ClientHand::getSeatsList() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return seatsList;
}
PlayerList
ClientHand::getActivePlayerList() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return activePlayerList;
}
PlayerList
ClientHand::getRunningPlayerList() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return runningPlayerList;
}
PlayerListIterator
ClientHand::getSeatIt(unsigned uniqueId) const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
PlayerListIterator it;
for(it=seatsList->begin(); it!=seatsList->end(); it++) {
@@ -100,6 +104,7 @@ ClientHand::getSeatIt(unsigned uniqueId) const
PlayerListIterator
ClientHand::getActivePlayerIt(unsigned uniqueId) const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
PlayerListIterator it;
for(it=activePlayerList->begin(); it!=activePlayerList->end(); it++) {
@@ -114,6 +119,7 @@ ClientHand::getActivePlayerIt(unsigned uniqueId) const
PlayerListIterator
ClientHand::getRunningPlayerIt(unsigned uniqueId) const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
PlayerListIterator it;
for(it=runningPlayerList->begin(); it!=runningPlayerList->end(); it++) {
@@ -297,13 +303,15 @@ ClientHand::getLastPlayersTurn() const
void
ClientHand::setLastActionPlayer (unsigned theValue)
{
lastActionPlayer = theValue;
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
lastActionPlayer = theValue;
}
unsigned
ClientHand::getLastActionPlayer() const
{
return lastActionPlayer;
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return lastActionPlayer;
}
void
+6 -5
View File
@@ -42,10 +42,6 @@ class ClientHand : public HandInterface
PlayerList getActivePlayerList() const;
PlayerList getRunningPlayerList() const;
PlayerListIterator getSeatIt(unsigned) const;
PlayerListIterator getActivePlayerIt(unsigned) const;
PlayerListIterator getRunningPlayerIt(unsigned) const;
boost::shared_ptr<BoardInterface> getBoard() const;
boost::shared_ptr<BeRoInterface> getPreflop() const;
boost::shared_ptr<BeRoInterface> getFlop() const;
@@ -92,8 +88,13 @@ class ClientHand : public HandInterface
void switchRounds();
protected:
PlayerListIterator getSeatIt(unsigned) const;
PlayerListIterator getActivePlayerIt(unsigned) const;
PlayerListIterator getRunningPlayerIt(unsigned) const;
private:
private:
mutable boost::recursive_mutex m_syncMutex;
boost::shared_ptr<EngineFactory> myFactory;
+4 -4
View File
@@ -217,15 +217,15 @@ ClientPlayer::getMyActiveStatus() const
void
ClientPlayer::setMyStayOnTableStatus(bool theValue)
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myStayOnTableStatus = theValue;
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
myStayOnTableStatus = theValue;
}
bool
ClientPlayer::getMyStayOnTableStatus() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myStayOnTableStatus;
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myStayOnTableStatus;
}
void