So before I went and posted ~800 lines of code, I have 2 questions:
1: What is the preferred way for us to post "complex" C++ (of course, this is just a .h, .cpp, and main cpp but it's still a lot of lines) that wont just be obnoxious to read/debug? (I guess.. what is the proper etiquette here?)
2: Maybe I don't have to post it, and I can get theory help - I have a socket server that spawns threads with mutexes to control everything as needed (I think I am doing it right). When I run on my dev machine (4 cores), I get about 22% usage spikes every 5 seconds on 2 of the cores. When I put it on my "server" it's a single core, and it spikes to 100%.
I have put
std::couts in all the while loops and none of them run more than the initial entry (recv/accept are blocking, all the other mutexes hold just fine). Is there a better approach to debugging this, or are accept/recv just that cpu intensive?
I am not yet doing event driven threads (and I am not using select, but if I have to I will refactor, but I would like to understand how to do it "right" without it as part of the learning exercise).
For reference: Windows server 2012 R2, Single Core 2Ghz, 1Gb RAM. IIS is running, the server is fairly locked down and all security updates/patches are installed. I do monitor any additional processes running, and nothing is odd or unexpected on the vm.
Threads are created using CreateThread(...); Mutexes are locked with WaitForSingleObject(...);
Sorry for the length, and thank you!
Edited by ryantroop