Improve thread safety.
This commit is contained in:
@@ -36,10 +36,6 @@ public:
|
||||
virtual PlayerList getActivePlayerList() const =0;
|
||||
virtual PlayerList getRunningPlayerList() const =0;
|
||||
|
||||
virtual PlayerListIterator getSeatIt(unsigned) const =0;
|
||||
virtual PlayerListIterator getActivePlayerIt(unsigned) const =0;
|
||||
virtual PlayerListIterator getRunningPlayerIt(unsigned) const =0;
|
||||
|
||||
virtual boost::shared_ptr<BoardInterface> getBoard() const =0;
|
||||
virtual boost::shared_ptr<BeRoInterface> getPreflop() const =0;
|
||||
virtual boost::shared_ptr<BeRoInterface> getFlop() const =0;
|
||||
@@ -83,6 +79,18 @@ public:
|
||||
|
||||
virtual void switchRounds() =0;
|
||||
|
||||
protected:
|
||||
virtual PlayerListIterator getSeatIt(unsigned) const =0;
|
||||
virtual PlayerListIterator getActivePlayerIt(unsigned) const =0;
|
||||
virtual PlayerListIterator getRunningPlayerIt(unsigned) const =0;
|
||||
|
||||
friend class Game;
|
||||
friend class LocalBeRo;
|
||||
friend class LocalBeRoPreflop;
|
||||
friend class LocalBeRoFlop;
|
||||
friend class LocalBeRoTurn;
|
||||
friend class LocalBeRoRiver;
|
||||
friend class LocalBeRoPostRiver;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -42,10 +42,6 @@ public:
|
||||
PlayerList getActivePlayerList() const {return activePlayerList;}
|
||||
PlayerList getRunningPlayerList() const {return runningPlayerList;}
|
||||
|
||||
PlayerListIterator getSeatIt(unsigned) const;
|
||||
PlayerListIterator getActivePlayerIt(unsigned) const;
|
||||
PlayerListIterator getRunningPlayerIt(unsigned) const;
|
||||
|
||||
boost::shared_ptr<BoardInterface> getBoard() const { return myBoard; }
|
||||
boost::shared_ptr<BeRoInterface> getPreflop() const { return myBeRo[GAME_STATE_PREFLOP]; }
|
||||
boost::shared_ptr<BeRoInterface> getFlop() const { return myBeRo[GAME_STATE_FLOP]; }
|
||||
@@ -91,6 +87,10 @@ public:
|
||||
|
||||
void switchRounds();
|
||||
|
||||
protected:
|
||||
PlayerListIterator getSeatIt(unsigned) const;
|
||||
PlayerListIterator getActivePlayerIt(unsigned) const;
|
||||
PlayerListIterator getRunningPlayerIt(unsigned) const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1732,6 +1732,9 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client
|
||||
cardDataStream >> myCards[0];
|
||||
cardDataStream >> myCards[1];
|
||||
}
|
||||
// Basic synchronisation before a new hand is started.
|
||||
client->GetGui().waitForGuiUpdateDone();
|
||||
// Start new hand.
|
||||
client->GetGame()->getSeatsList()->front()->setMyCards(myCards);
|
||||
client->GetGame()->initHand();
|
||||
client->GetGame()->getCurrentHand()->setSmallBlind(netHandStart->smallBlind);
|
||||
|
||||
@@ -1219,7 +1219,7 @@ void
|
||||
ClientThread::RemoveDisconnectedPlayers()
|
||||
{
|
||||
// This should only be called between hands.
|
||||
if (m_game.get())
|
||||
if (m_game)
|
||||
{
|
||||
PlayerListIterator it;
|
||||
for (it = m_game->getSeatsList()->begin(); it != m_game->getSeatsList()->end(); it++)
|
||||
|
||||
Reference in New Issue
Block a user