highfidelity/hifi — pull request #2271 by ZappoMan (2014-03-12 04:18:52+00:00)
Title: Fix runaway JurisdictionListener thread and other improvements

* fixed a bug in JurisdictionListener that it wasn't yielding at all... therefore wasting lots of CPU cycles
* improve general thread performance of PacketSender and ReceivedPacketProcessor by switching to use QWaitCondition instead of micro-sleeps

-------------
**Profile BEFORE:**
```
Running Time	Self	Symbol Name
3724.0ms 11.6%	3724.0	std::vector >::size() const
1595.0ms 4.9%	0.0	ReceivedPacketProcessor::process()
1593.0ms 4.9%	0.0	JurisdictionListener::process()
2.0ms 0.0%	0.0	GenericThread::threadRoutine()
1127.0ms 3.5%	0.0	PacketSender::nonThreadedProcess()
1127.0ms 3.5%	0.0	PacketSender::process()
1127.0ms 3.5%	0.0	JurisdictionListener::process()
925.0ms 2.8%	0.0	PacketSender::hasPacketsToSend() const
925.0ms 2.8%	0.0	JurisdictionListener::process()
76.0ms 0.2%	0.0
1.0ms 0.0%	0.0	PacketSender::threadedProcess()
3636.0ms 11.3%	3636.0	mach_absolute_time
3135.0ms 9.7%	3135.0	__commpage_gettimeofday
2229.0ms 6.9%	2229.0	PacketSender::nonThreadedProcess()
1354.0ms 4.2%	1354.0	SimpleMovingAverage::updateAverage(float)
546.0ms 1.7%	546.0	JurisdictionListener::process()
506.0ms 1.5%	506.0	QMutex::lock()
469.0ms 1.4%	469.0	GenericThread::isStillRunning() const
467.0ms 1.4%	467.0	gettimeofday
440.0ms 1.3%	440.0	QMutex::unlock()
391.0ms 1.2%	391.0	szone_malloc_should_clear
381.0ms 1.1%	381.0	JurisdictionListener::queueJurisdictionRequest()
```

-------------
**Profile AFTER:**
```
Running Time	Self	Symbol Name
820.0ms 6.5%	820.0	mach_msg_trap
589.0ms 4.7%	589.0	glm::detail::tvec3::tvec3(float const&, float const&, float const&)
532.0ms 4.2%	532.0	glm::detail::tvec3 glm::detail::operator*(glm::detail::tvec3 const&, glm::detail::tvec3 const&)
530.0ms 4.2%	530.0	glm::detail::tvec3::tvec3(glm::detail::tvec3 const&)
405.0ms 3.2%	405.0	ViewFrustum::boxInFrustum(AABox const&) const
323.0ms 2.5%	323.0	BuckyBalls::simulate(float, HandData const*)
318.0ms 2.5%	318.0	Plane::distance(glm::detail::tvec3 const&) const
311.0ms 2.4%	311.0	glm::detail::compute_dot::call(glm::detail::tvec3 const&, glm::detail::tvec3 const&)
248.0ms 1.9%	248.0	glm::detail::tvec3::tvec3(float const&, float const&, float const&)
243.0ms 1.9%	243.0	float glm::length(glm::detail::tvec3 const&)
229.0ms 1.8%	229.0	AABox::getVertexN(glm::detail::tvec3 const&) const
200.0ms 1.6%	200.0	AABox::getVertexP(glm::detail::tvec3 const&) const
197.0ms 1.5%	197.0	std::sqrt(float)
165.0ms 1.3%	165.0	glm::detail::tvec3 glm::detail::operator-(glm::detail::tvec3 const&, glm::detail::tvec3 const&)
147.0ms 1.1%	147.0	glm::detail::tvec3::tvec3(glm::detail::tvec3 const&)
142.0ms 1.1%	142.0	OctreeElement::getChildAtIndex(int) const
135.0ms 1.0%	135.0	float glm::dot(glm::detail::tvec3 const&, glm::detail::tvec3 const)
111.0ms 0.8%	111.0	glm::detail::tvec1::tvec1(float const&)
108.0ms 0.8%	108.0	glm::detail::tvec3 glm::detail::operator*(glm::detail::tvec3 const&, float const&)
107.0ms 0.8%	107.0	glm::detail::tvec4::tvec4(float const&, float const&, float const&, float const&)
99.0ms 0.7%	99.0	numberOfOnes(unsigned char)
```