Skip to content

Commit

Permalink
Ordered sendq (once more with feeling edition)
Browse files Browse the repository at this point in the history
Implemented ordering by use of a lock-and-pulse queue.  This
mechanism does use a syncroot and thus isn't lock free, but
performs far better than the previous iterations.  The
SendData mechanism has been reverted as this method no longer
relies on the allocations of sequences.

CPU has been drastically reduced because of the reduction in
looping in the write threads, and sits between 0-2% with 35
players in live testing.

Fixes Pryaxis/TShock#1049, #27, #26, #9
  • Loading branch information
tylerjwatson committed Jul 30, 2015
1 parent 0deb74f commit 8e5d593
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 291 deletions.
9 changes: 3 additions & 6 deletions Terraria/MessageBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,6 @@ public void GetData(int start, int length)
}
case 31:
{
LinkedList<SequenceItem> sequence = new LinkedList<SequenceItem>();
if (Main.netMode != 2)
{
return;
Expand All @@ -1640,18 +1639,16 @@ public void GetData(int start, int length)
}
for (int t1 = 0; t1 < 40; t1++)
{
NetMessage.SendData(sequence, 32, this.whoAmI, -1, "", num81, (float)t1, 0f, 0f, 0, 0, 0);
NetMessage.SendData(32, this.whoAmI, -1, "", num81, (float)t1, 0f, 0f, 0, 0, 0);
}
NetMessage.SendData(sequence, 33, this.whoAmI, -1, "", num81, 0f, 0f, 0f, 0, 0, 0);
NetMessage.SendData(33, this.whoAmI, -1, "", num81, 0f, 0f, 0f, 0, 0, 0);
Main.player[this.whoAmI].chest = num81;
if (Main.myPlayer == this.whoAmI)
{
Main.recBigList = false;
}
Recipe.FindRecipes();
NetMessage.SendData(sequence, 80, -1, this.whoAmI, "", this.whoAmI, (float)num81, 0f, 0f, 0, 0, 0);

Netplay.Clients[this.whoAmI].sendQueue.Enqueue(sequence);
NetMessage.SendData(80, -1, this.whoAmI, "", this.whoAmI, (float)num81, 0f, 0f, 0, 0, 0);

if (Main.tile[num79, num80].frameX < 36 || Main.tile[num79, num80].frameX >= 72)
{
Expand Down
Loading

0 comments on commit 8e5d593

Please sign in to comment.