mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
switch from pthread mutex to QMutex
This commit is contained in:
parent
2c30b8b5b4
commit
9bc4a3df41
12 changed files with 111 additions and 131 deletions
|
@ -74,9 +74,6 @@ VoxelSystem::VoxelSystem(float treeScale, int maxVoxels)
|
||||||
_tree = new VoxelTree();
|
_tree = new VoxelTree();
|
||||||
|
|
||||||
_tree->getRoot()->setVoxelSystem(this);
|
_tree->getRoot()->setVoxelSystem(this);
|
||||||
pthread_mutex_init(&_bufferWriteLock, NULL);
|
|
||||||
pthread_mutex_init(&_treeLock, NULL);
|
|
||||||
pthread_mutex_init(&_freeIndexLock, NULL);
|
|
||||||
|
|
||||||
VoxelTreeElement::addDeleteHook(this);
|
VoxelTreeElement::addDeleteHook(this);
|
||||||
VoxelTreeElement::addUpdateHook(this);
|
VoxelTreeElement::addUpdateHook(this);
|
||||||
|
@ -188,10 +185,10 @@ glBufferIndex VoxelSystem::getNextBufferIndex() {
|
||||||
glBufferIndex output = GLBUFFER_INDEX_UNKNOWN;
|
glBufferIndex output = GLBUFFER_INDEX_UNKNOWN;
|
||||||
// if there's a free index, use it...
|
// if there's a free index, use it...
|
||||||
if (_freeIndexes.size() > 0) {
|
if (_freeIndexes.size() > 0) {
|
||||||
pthread_mutex_lock(&_freeIndexLock);
|
_freeIndexLock.lock();
|
||||||
output = _freeIndexes.back();
|
output = _freeIndexes.back();
|
||||||
_freeIndexes.pop_back();
|
_freeIndexes.pop_back();
|
||||||
pthread_mutex_unlock(&_freeIndexLock);
|
_freeIndexLock.unlock();
|
||||||
} else {
|
} else {
|
||||||
output = _voxelsInWriteArrays;
|
output = _voxelsInWriteArrays;
|
||||||
_voxelsInWriteArrays++;
|
_voxelsInWriteArrays++;
|
||||||
|
@ -222,9 +219,9 @@ void VoxelSystem::freeBufferIndex(glBufferIndex index) {
|
||||||
}
|
}
|
||||||
if (!inList) {
|
if (!inList) {
|
||||||
// make the index available for next node that needs to be drawn
|
// make the index available for next node that needs to be drawn
|
||||||
pthread_mutex_lock(&_freeIndexLock);
|
_freeIndexLock.lock();
|
||||||
_freeIndexes.push_back(index);
|
_freeIndexes.push_back(index);
|
||||||
pthread_mutex_unlock(&_freeIndexLock);
|
_freeIndexLock.unlock();
|
||||||
|
|
||||||
// make the VBO slot "invisible" in case this slot is not used
|
// make the VBO slot "invisible" in case this slot is not used
|
||||||
const glm::vec3 startVertex(FLT_MAX, FLT_MAX, FLT_MAX);
|
const glm::vec3 startVertex(FLT_MAX, FLT_MAX, FLT_MAX);
|
||||||
|
@ -243,14 +240,14 @@ void VoxelSystem::clearFreeBufferIndexes() {
|
||||||
|
|
||||||
// clear out freeIndexes
|
// clear out freeIndexes
|
||||||
{
|
{
|
||||||
PerformanceWarning warn(showWarnings,"clearFreeBufferIndexes() : pthread_mutex_lock(&_freeIndexLock)");
|
PerformanceWarning warn(showWarnings,"clearFreeBufferIndexes() : _freeIndexLock.lock()");
|
||||||
pthread_mutex_lock(&_freeIndexLock);
|
_freeIndexLock.lock();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
PerformanceWarning warn(showWarnings,"clearFreeBufferIndexes() : _freeIndexes.clear()");
|
PerformanceWarning warn(showWarnings,"clearFreeBufferIndexes() : _freeIndexes.clear()");
|
||||||
_freeIndexes.clear();
|
_freeIndexes.clear();
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&_freeIndexLock);
|
_freeIndexLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
VoxelSystem::~VoxelSystem() {
|
VoxelSystem::~VoxelSystem() {
|
||||||
|
@ -259,9 +256,6 @@ VoxelSystem::~VoxelSystem() {
|
||||||
|
|
||||||
cleanupVoxelMemory();
|
cleanupVoxelMemory();
|
||||||
delete _tree;
|
delete _tree;
|
||||||
pthread_mutex_destroy(&_bufferWriteLock);
|
|
||||||
pthread_mutex_destroy(&_treeLock);
|
|
||||||
pthread_mutex_destroy(&_freeIndexLock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelSystem::setMaxVoxels(int maxVoxels) {
|
void VoxelSystem::setMaxVoxels(int maxVoxels) {
|
||||||
|
@ -345,7 +339,7 @@ void VoxelSystem::setVoxelsAsPoints(bool voxelsAsPoints) {
|
||||||
|
|
||||||
void VoxelSystem::cleanupVoxelMemory() {
|
void VoxelSystem::cleanupVoxelMemory() {
|
||||||
if (_initialized) {
|
if (_initialized) {
|
||||||
pthread_mutex_lock(&_bufferWriteLock);
|
_bufferWriteLock.lock();
|
||||||
_initialized = false; // no longer initialized
|
_initialized = false; // no longer initialized
|
||||||
if (_useVoxelShader) {
|
if (_useVoxelShader) {
|
||||||
// these are used when in VoxelShader mode.
|
// these are used when in VoxelShader mode.
|
||||||
|
@ -383,7 +377,7 @@ void VoxelSystem::cleanupVoxelMemory() {
|
||||||
delete[] _writeVoxelDirtyArray;
|
delete[] _writeVoxelDirtyArray;
|
||||||
delete[] _readVoxelDirtyArray;
|
delete[] _readVoxelDirtyArray;
|
||||||
_writeVoxelDirtyArray = _readVoxelDirtyArray = NULL;
|
_writeVoxelDirtyArray = _readVoxelDirtyArray = NULL;
|
||||||
pthread_mutex_unlock(&_bufferWriteLock);
|
_bufferWriteLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,7 +410,7 @@ void VoxelSystem::setupFaceIndices(GLuint& faceVBOID, GLubyte faceIdentityIndice
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelSystem::initVoxelMemory() {
|
void VoxelSystem::initVoxelMemory() {
|
||||||
pthread_mutex_lock(&_bufferWriteLock);
|
_bufferWriteLock.lock();
|
||||||
|
|
||||||
_memoryUsageRAM = 0;
|
_memoryUsageRAM = 0;
|
||||||
_memoryUsageVBO = 0; // our VBO allocations as we know them
|
_memoryUsageVBO = 0; // our VBO allocations as we know them
|
||||||
|
@ -531,7 +525,7 @@ void VoxelSystem::initVoxelMemory() {
|
||||||
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
|
|
||||||
pthread_mutex_unlock(&_bufferWriteLock);
|
_bufferWriteLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelSystem::writeToSVOFile(const char* filename, VoxelTreeElement* element) const {
|
void VoxelSystem::writeToSVOFile(const char* filename, VoxelTreeElement* element) const {
|
||||||
|
@ -685,7 +679,7 @@ void VoxelSystem::setupNewVoxelsForDrawing() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// lock on the buffer write lock so we can't modify the data when the GPU is reading it
|
// lock on the buffer write lock so we can't modify the data when the GPU is reading it
|
||||||
pthread_mutex_lock(&_bufferWriteLock);
|
_bufferWriteLock.lock();
|
||||||
|
|
||||||
if (_voxelsUpdated) {
|
if (_voxelsUpdated) {
|
||||||
_voxelsDirty=true;
|
_voxelsDirty=true;
|
||||||
|
@ -694,7 +688,7 @@ void VoxelSystem::setupNewVoxelsForDrawing() {
|
||||||
// copy the newly written data to the arrays designated for reading, only does something if _voxelsDirty && _voxelsUpdated
|
// copy the newly written data to the arrays designated for reading, only does something if _voxelsDirty && _voxelsUpdated
|
||||||
copyWrittenDataToReadArrays(didWriteFullVBO);
|
copyWrittenDataToReadArrays(didWriteFullVBO);
|
||||||
|
|
||||||
pthread_mutex_unlock(&_bufferWriteLock);
|
_bufferWriteLock.unlock();
|
||||||
|
|
||||||
uint64_t end = usecTimestampNow();
|
uint64_t end = usecTimestampNow();
|
||||||
int elapsedmsec = (end - start) / 1000;
|
int elapsedmsec = (end - start) / 1000;
|
||||||
|
@ -725,8 +719,8 @@ void VoxelSystem::setupNewVoxelsForDrawingSingleNode(bool allowBailEarly) {
|
||||||
// lock on the buffer write lock so we can't modify the data when the GPU is reading it
|
// lock on the buffer write lock so we can't modify the data when the GPU is reading it
|
||||||
{
|
{
|
||||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
"setupNewVoxelsForDrawingSingleNode()... pthread_mutex_lock(&_bufferWriteLock);");
|
"setupNewVoxelsForDrawingSingleNode()... _bufferWriteLock.lock();" );
|
||||||
pthread_mutex_lock(&_bufferWriteLock);
|
_bufferWriteLock.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
_voxelsDirty = true; // if we got this far, then we can assume some voxels are dirty
|
_voxelsDirty = true; // if we got this far, then we can assume some voxels are dirty
|
||||||
|
@ -737,7 +731,7 @@ void VoxelSystem::setupNewVoxelsForDrawingSingleNode(bool allowBailEarly) {
|
||||||
// after...
|
// after...
|
||||||
_voxelsUpdated = 0;
|
_voxelsUpdated = 0;
|
||||||
|
|
||||||
pthread_mutex_unlock(&_bufferWriteLock);
|
_bufferWriteLock.unlock();
|
||||||
|
|
||||||
uint64_t end = usecTimestampNow();
|
uint64_t end = usecTimestampNow();
|
||||||
int elapsedmsec = (end - start) / 1000;
|
int elapsedmsec = (end - start) / 1000;
|
||||||
|
@ -2766,13 +2760,13 @@ unsigned long VoxelSystem::getVoxelMemoryUsageGPU() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelSystem::lockTree() {
|
void VoxelSystem::lockTree() {
|
||||||
pthread_mutex_lock(&_treeLock);
|
_treeLock.lock();
|
||||||
_treeIsBusy = true;
|
_treeIsBusy = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelSystem::unlockTree() {
|
void VoxelSystem::unlockTree() {
|
||||||
_treeIsBusy = false;
|
_treeIsBusy = false;
|
||||||
pthread_mutex_unlock(&_treeLock);
|
_treeLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -260,8 +260,8 @@ private:
|
||||||
GLuint _vboIndicesFront;
|
GLuint _vboIndicesFront;
|
||||||
GLuint _vboIndicesBack;
|
GLuint _vboIndicesBack;
|
||||||
|
|
||||||
pthread_mutex_t _bufferWriteLock;
|
QMutex _bufferWriteLock;
|
||||||
pthread_mutex_t _treeLock;
|
QMutex _treeLock;
|
||||||
|
|
||||||
ViewFrustum _lastKnownViewFrustum;
|
ViewFrustum _lastKnownViewFrustum;
|
||||||
ViewFrustum _lastStableViewFrustum;
|
ViewFrustum _lastStableViewFrustum;
|
||||||
|
@ -287,7 +287,7 @@ private:
|
||||||
|
|
||||||
int _hookID;
|
int _hookID;
|
||||||
std::vector<glBufferIndex> _freeIndexes;
|
std::vector<glBufferIndex> _freeIndexes;
|
||||||
pthread_mutex_t _freeIndexLock;
|
QMutex _freeIndexLock;
|
||||||
|
|
||||||
void freeBufferIndex(glBufferIndex index);
|
void freeBufferIndex(glBufferIndex index);
|
||||||
void clearFreeBufferIndexes();
|
void clearFreeBufferIndexes();
|
||||||
|
|
|
@ -111,11 +111,11 @@ void LogDialog::resizeEvent(QResizeEvent*) {
|
||||||
|
|
||||||
void LogDialog::appendLogLine(QString logLine) {
|
void LogDialog::appendLogLine(QString logLine) {
|
||||||
if (isVisible()) {
|
if (isVisible()) {
|
||||||
pthread_mutex_lock(& _mutex);
|
_mutex.lock();
|
||||||
if (logLine.contains(_searchTerm, Qt::CaseInsensitive)) {
|
if (logLine.contains(_searchTerm, Qt::CaseInsensitive)) {
|
||||||
_logTextBox->appendPlainText(logLine.simplified());
|
_logTextBox->appendPlainText(logLine.simplified());
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(& _mutex);
|
_mutex.unlock();
|
||||||
_logTextBox->ensureCursorVisible();
|
_logTextBox->ensureCursorVisible();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,13 +140,12 @@ void LogDialog::handleSearchTextChanged(const QString searchText) {
|
||||||
|
|
||||||
void LogDialog::showLogData() {
|
void LogDialog::showLogData() {
|
||||||
_logTextBox->clear();
|
_logTextBox->clear();
|
||||||
pthread_mutex_lock(& _mutex);
|
_mutex.lock();
|
||||||
QStringList _logData = _logger->getLogData();
|
QStringList _logData = _logger->getLogData();
|
||||||
for (int i = 0; i < _logData.size(); ++i) {
|
for (int i = 0; i < _logData.size(); ++i) {
|
||||||
appendLogLine(_logData[i]);
|
appendLogLine(_logData[i]);
|
||||||
}
|
}
|
||||||
|
_mutex.unlock();
|
||||||
pthread_mutex_unlock(& _mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KeywordHighlighter::KeywordHighlighter(QTextDocument *parent) : QSyntaxHighlighter(parent), keywordFormat() {
|
KeywordHighlighter::KeywordHighlighter(QTextDocument *parent) : QSyntaxHighlighter(parent), keywordFormat() {
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
#define __interface__LogDialog__
|
#define __interface__LogDialog__
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QMutex>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QSyntaxHighlighter>
|
#include <QSyntaxHighlighter>
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include "AbstractLoggerInterface.h"
|
#include "AbstractLoggerInterface.h"
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTextCharFormat keywordFormat;
|
QTextCharFormat keywordFormat;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class LogDialog : public QDialog {
|
class LogDialog : public QDialog {
|
||||||
|
@ -60,7 +60,7 @@ private:
|
||||||
QCheckBox* _extraDebuggingBox;
|
QCheckBox* _extraDebuggingBox;
|
||||||
QPushButton* _revealLogButton;
|
QPushButton* _revealLogButton;
|
||||||
QPlainTextEdit* _logTextBox;
|
QPlainTextEdit* _logTextBox;
|
||||||
pthread_mutex_t _mutex;
|
QMutex _mutex;
|
||||||
QString _searchTerm;
|
QString _searchTerm;
|
||||||
KeywordHighlighter* _highlighter;
|
KeywordHighlighter* _highlighter;
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,9 @@ JurisdictionSender::JurisdictionSender(JurisdictionMap* map, NODE_TYPE type, Pac
|
||||||
_jurisdictionMap(map)
|
_jurisdictionMap(map)
|
||||||
{
|
{
|
||||||
_nodeType = type;
|
_nodeType = type;
|
||||||
pthread_mutex_init(&_requestingNodeMutex, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JurisdictionSender::~JurisdictionSender() {
|
JurisdictionSender::~JurisdictionSender() {
|
||||||
pthread_mutex_destroy(&_requestingNodeMutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#define __shared__JurisdictionSender__
|
#define __shared__JurisdictionSender__
|
||||||
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
#include <PacketSender.h>
|
#include <PacketSender.h>
|
||||||
#include <ReceivedPacketProcessor.h>
|
#include <ReceivedPacketProcessor.h>
|
||||||
|
@ -38,14 +39,14 @@ protected:
|
||||||
virtual void processPacket(const HifiSockAddr& senderAddress, unsigned char* packetData, ssize_t packetLength);
|
virtual void processPacket(const HifiSockAddr& senderAddress, unsigned char* packetData, ssize_t packetLength);
|
||||||
|
|
||||||
/// Locks all the resources of the thread.
|
/// Locks all the resources of the thread.
|
||||||
void lockRequestingNodes() { pthread_mutex_lock(&_requestingNodeMutex); }
|
void lockRequestingNodes() { _requestingNodeMutex.lock(); }
|
||||||
|
|
||||||
/// Unlocks all the resources of the thread.
|
/// Unlocks all the resources of the thread.
|
||||||
void unlockRequestingNodes() { pthread_mutex_unlock(&_requestingNodeMutex); }
|
void unlockRequestingNodes() { _requestingNodeMutex.unlock(); }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
pthread_mutex_t _requestingNodeMutex;
|
QMutex _requestingNodeMutex;
|
||||||
JurisdictionMap* _jurisdictionMap;
|
JurisdictionMap* _jurisdictionMap;
|
||||||
std::queue<QUuid> _nodesRequestingJurisdictions;
|
std::queue<QUuid> _nodesRequestingJurisdictions;
|
||||||
NODE_TYPE _nodeType;
|
NODE_TYPE _nodeType;
|
||||||
|
|
|
@ -43,20 +43,12 @@ Octree::Octree(bool shouldReaverage) :
|
||||||
_shouldReaverage(shouldReaverage),
|
_shouldReaverage(shouldReaverage),
|
||||||
_stopImport(false) {
|
_stopImport(false) {
|
||||||
_rootNode = NULL;
|
_rootNode = NULL;
|
||||||
|
|
||||||
pthread_mutex_init(&_encodeSetLock, NULL);
|
|
||||||
pthread_mutex_init(&_deleteSetLock, NULL);
|
|
||||||
pthread_mutex_init(&_deletePendingSetLock, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Octree::~Octree() {
|
Octree::~Octree() {
|
||||||
// delete the children of the root node
|
// delete the children of the root node
|
||||||
// this recursively deletes the tree
|
// this recursively deletes the tree
|
||||||
delete _rootNode;
|
delete _rootNode;
|
||||||
|
|
||||||
pthread_mutex_destroy(&_encodeSetLock);
|
|
||||||
pthread_mutex_destroy(&_deleteSetLock);
|
|
||||||
pthread_mutex_destroy(&_deletePendingSetLock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recurses voxel tree calling the RecurseOctreeOperation function for each node.
|
// Recurses voxel tree calling the RecurseOctreeOperation function for each node.
|
||||||
|
@ -1504,53 +1496,53 @@ void dumpSetContents(const char* name, std::set<unsigned char*> set) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Octree::startEncoding(OctreeElement* node) {
|
void Octree::startEncoding(OctreeElement* node) {
|
||||||
pthread_mutex_lock(&_encodeSetLock);
|
_encodeSetLock.lock();
|
||||||
_codesBeingEncoded.insert(node->getOctalCode());
|
_codesBeingEncoded.insert(node->getOctalCode());
|
||||||
pthread_mutex_unlock(&_encodeSetLock);
|
_encodeSetLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Octree::doneEncoding(OctreeElement* node) {
|
void Octree::doneEncoding(OctreeElement* node) {
|
||||||
pthread_mutex_lock(&_encodeSetLock);
|
_encodeSetLock.lock();
|
||||||
_codesBeingEncoded.erase(node->getOctalCode());
|
_codesBeingEncoded.erase(node->getOctalCode());
|
||||||
pthread_mutex_unlock(&_encodeSetLock);
|
_encodeSetLock.unlock();
|
||||||
|
|
||||||
// if we have any pending delete codes, then delete them now.
|
// if we have any pending delete codes, then delete them now.
|
||||||
emptyDeleteQueue();
|
emptyDeleteQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Octree::startDeleting(const unsigned char* code) {
|
void Octree::startDeleting(const unsigned char* code) {
|
||||||
pthread_mutex_lock(&_deleteSetLock);
|
_deleteSetLock.lock();
|
||||||
_codesBeingDeleted.insert(code);
|
_codesBeingDeleted.insert(code);
|
||||||
pthread_mutex_unlock(&_deleteSetLock);
|
_deleteSetLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Octree::doneDeleting(const unsigned char* code) {
|
void Octree::doneDeleting(const unsigned char* code) {
|
||||||
pthread_mutex_lock(&_deleteSetLock);
|
_deleteSetLock.lock();
|
||||||
_codesBeingDeleted.erase(code);
|
_codesBeingDeleted.erase(code);
|
||||||
pthread_mutex_unlock(&_deleteSetLock);
|
_deleteSetLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Octree::isEncoding(const unsigned char* codeBuffer) {
|
bool Octree::isEncoding(const unsigned char* codeBuffer) {
|
||||||
pthread_mutex_lock(&_encodeSetLock);
|
_encodeSetLock.lock();
|
||||||
bool isEncoding = (_codesBeingEncoded.find(codeBuffer) != _codesBeingEncoded.end());
|
bool isEncoding = (_codesBeingEncoded.find(codeBuffer) != _codesBeingEncoded.end());
|
||||||
pthread_mutex_unlock(&_encodeSetLock);
|
_encodeSetLock.unlock();
|
||||||
return isEncoding;
|
return isEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Octree::queueForLaterDelete(const unsigned char* codeBuffer) {
|
void Octree::queueForLaterDelete(const unsigned char* codeBuffer) {
|
||||||
pthread_mutex_lock(&_deletePendingSetLock);
|
_deletePendingSetLock.lock();
|
||||||
_codesPendingDelete.insert(codeBuffer);
|
_codesPendingDelete.insert(codeBuffer);
|
||||||
pthread_mutex_unlock(&_deletePendingSetLock);
|
_deletePendingSetLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Octree::emptyDeleteQueue() {
|
void Octree::emptyDeleteQueue() {
|
||||||
pthread_mutex_lock(&_deletePendingSetLock);
|
_deletePendingSetLock.lock();
|
||||||
for (std::set<const unsigned char*>::iterator i = _codesPendingDelete.begin(); i != _codesPendingDelete.end(); ++i) {
|
for (std::set<const unsigned char*>::iterator i = _codesPendingDelete.begin(); i != _codesPendingDelete.end(); ++i) {
|
||||||
const unsigned char* codeToDelete = *i;
|
const unsigned char* codeToDelete = *i;
|
||||||
_codesBeingDeleted.erase(codeToDelete);
|
_codesBeingDeleted.erase(codeToDelete);
|
||||||
deleteOctalCodeFromTree(codeToDelete, COLLAPSE_EMPTY_TREE);
|
deleteOctalCodeFromTree(codeToDelete, COLLAPSE_EMPTY_TREE);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&_deletePendingSetLock);
|
_deletePendingSetLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Octree::cancelImport() {
|
void Octree::cancelImport() {
|
||||||
|
|
|
@ -72,12 +72,12 @@ public:
|
||||||
OctreeSceneStats* stats;
|
OctreeSceneStats* stats;
|
||||||
CoverageMap* map;
|
CoverageMap* map;
|
||||||
JurisdictionMap* jurisdictionMap;
|
JurisdictionMap* jurisdictionMap;
|
||||||
|
|
||||||
// output hints from the encode process
|
// output hints from the encode process
|
||||||
typedef enum {
|
typedef enum {
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
DIDNT_FIT,
|
DIDNT_FIT,
|
||||||
NULL_NODE,
|
NULL_NODE,
|
||||||
TOO_DEEP,
|
TOO_DEEP,
|
||||||
OUT_OF_JURISDICTION,
|
OUT_OF_JURISDICTION,
|
||||||
LOD_SKIP,
|
LOD_SKIP,
|
||||||
|
@ -87,14 +87,14 @@ public:
|
||||||
OCCLUDED
|
OCCLUDED
|
||||||
} reason;
|
} reason;
|
||||||
reason stopReason;
|
reason stopReason;
|
||||||
|
|
||||||
EncodeBitstreamParams(
|
EncodeBitstreamParams(
|
||||||
int maxEncodeLevel = INT_MAX,
|
int maxEncodeLevel = INT_MAX,
|
||||||
const ViewFrustum* viewFrustum = IGNORE_VIEW_FRUSTUM,
|
const ViewFrustum* viewFrustum = IGNORE_VIEW_FRUSTUM,
|
||||||
bool includeColor = WANT_COLOR,
|
bool includeColor = WANT_COLOR,
|
||||||
bool includeExistsBits = WANT_EXISTS_BITS,
|
bool includeExistsBits = WANT_EXISTS_BITS,
|
||||||
int chopLevels = 0,
|
int chopLevels = 0,
|
||||||
bool deltaViewFrustum = false,
|
bool deltaViewFrustum = false,
|
||||||
const ViewFrustum* lastViewFrustum = IGNORE_VIEW_FRUSTUM,
|
const ViewFrustum* lastViewFrustum = IGNORE_VIEW_FRUSTUM,
|
||||||
bool wantOcclusionCulling = NO_OCCLUSION_CULLING,
|
bool wantOcclusionCulling = NO_OCCLUSION_CULLING,
|
||||||
CoverageMap* map = IGNORE_COVERAGE_MAP,
|
CoverageMap* map = IGNORE_COVERAGE_MAP,
|
||||||
|
@ -122,13 +122,13 @@ public:
|
||||||
jurisdictionMap(jurisdictionMap),
|
jurisdictionMap(jurisdictionMap),
|
||||||
stopReason(UNKNOWN)
|
stopReason(UNKNOWN)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void displayStopReason() {
|
void displayStopReason() {
|
||||||
printf("StopReason: ");
|
printf("StopReason: ");
|
||||||
switch (stopReason) {
|
switch (stopReason) {
|
||||||
default:
|
default:
|
||||||
case UNKNOWN: printf("UNKNOWN\n"); break;
|
case UNKNOWN: printf("UNKNOWN\n"); break;
|
||||||
|
|
||||||
case DIDNT_FIT: printf("DIDNT_FIT\n"); break;
|
case DIDNT_FIT: printf("DIDNT_FIT\n"); break;
|
||||||
case NULL_NODE: printf("NULL_NODE\n"); break;
|
case NULL_NODE: printf("NULL_NODE\n"); break;
|
||||||
case TOO_DEEP: printf("TOO_DEEP\n"); break;
|
case TOO_DEEP: printf("TOO_DEEP\n"); break;
|
||||||
|
@ -158,9 +158,9 @@ public:
|
||||||
QUuid sourceUUID;
|
QUuid sourceUUID;
|
||||||
Node* sourceNode;
|
Node* sourceNode;
|
||||||
bool wantImportProgress;
|
bool wantImportProgress;
|
||||||
|
|
||||||
ReadBitstreamToTreeParams(
|
ReadBitstreamToTreeParams(
|
||||||
bool includeColor = WANT_COLOR,
|
bool includeColor = WANT_COLOR,
|
||||||
bool includeExistsBits = WANT_EXISTS_BITS,
|
bool includeExistsBits = WANT_EXISTS_BITS,
|
||||||
OctreeElement* destinationNode = NULL,
|
OctreeElement* destinationNode = NULL,
|
||||||
QUuid sourceUUID = QUuid(),
|
QUuid sourceUUID = QUuid(),
|
||||||
|
@ -180,7 +180,7 @@ class Octree : public QObject {
|
||||||
public:
|
public:
|
||||||
Octree(bool shouldReaverage = false);
|
Octree(bool shouldReaverage = false);
|
||||||
~Octree();
|
~Octree();
|
||||||
|
|
||||||
/// Your tree class must implement this to create the correct element type
|
/// Your tree class must implement this to create the correct element type
|
||||||
virtual OctreeElement* createNewElement(unsigned char * octalCode = NULL) const = 0;
|
virtual OctreeElement* createNewElement(unsigned char * octalCode = NULL) const = 0;
|
||||||
|
|
||||||
|
@ -209,8 +209,8 @@ public:
|
||||||
OctreeElement* getOrCreateChildElementAt(float x, float y, float z, float s);
|
OctreeElement* getOrCreateChildElementAt(float x, float y, float z, float s);
|
||||||
|
|
||||||
void recurseTreeWithOperation(RecurseOctreeOperation operation, void* extraData=NULL);
|
void recurseTreeWithOperation(RecurseOctreeOperation operation, void* extraData=NULL);
|
||||||
|
|
||||||
void recurseTreeWithOperationDistanceSorted(RecurseOctreeOperation operation,
|
void recurseTreeWithOperationDistanceSorted(RecurseOctreeOperation operation,
|
||||||
const glm::vec3& point, void* extraData=NULL);
|
const glm::vec3& point, void* extraData=NULL);
|
||||||
|
|
||||||
int encodeTreeBitstream(OctreeElement* node, OctreePacketData* packetData, OctreeElementBag& bag,
|
int encodeTreeBitstream(OctreeElement* node, OctreePacketData* packetData, OctreeElementBag& bag,
|
||||||
|
@ -223,9 +223,9 @@ public:
|
||||||
bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||||
OctreeElement*& node, float& distance, BoxFace& face);
|
OctreeElement*& node, float& distance, BoxFace& face);
|
||||||
|
|
||||||
bool findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration,
|
bool findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration,
|
||||||
void** penetratedObject = NULL);
|
void** penetratedObject = NULL);
|
||||||
|
|
||||||
bool findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration);
|
bool findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration);
|
||||||
|
|
||||||
// Note: this assumes the fileFormat is the HIO individual voxels code files
|
// Note: this assumes the fileFormat is the HIO individual voxels code files
|
||||||
|
@ -237,7 +237,7 @@ public:
|
||||||
// reads voxels from square image with alpha as a Y-axis
|
// reads voxels from square image with alpha as a Y-axis
|
||||||
bool readFromSquareARGB32Pixels(const char *filename);
|
bool readFromSquareARGB32Pixels(const char *filename);
|
||||||
bool readFromSchematicFile(const char* filename);
|
bool readFromSchematicFile(const char* filename);
|
||||||
|
|
||||||
// Octree does not currently handle its own locking, caller must use these to lock/unlock
|
// Octree does not currently handle its own locking, caller must use these to lock/unlock
|
||||||
void lockForRead() { lock.lockForRead(); }
|
void lockForRead() { lock.lockForRead(); }
|
||||||
void tryLockForRead() { lock.tryLockForRead(); }
|
void tryLockForRead() { lock.tryLockForRead(); }
|
||||||
|
@ -249,13 +249,13 @@ public:
|
||||||
|
|
||||||
void copySubTreeIntoNewTree(OctreeElement* startNode, Octree* destinationTree, bool rebaseToRoot);
|
void copySubTreeIntoNewTree(OctreeElement* startNode, Octree* destinationTree, bool rebaseToRoot);
|
||||||
void copyFromTreeIntoSubTree(Octree* sourceTree, OctreeElement* destinationNode);
|
void copyFromTreeIntoSubTree(Octree* sourceTree, OctreeElement* destinationNode);
|
||||||
|
|
||||||
bool getShouldReaverage() const { return _shouldReaverage; }
|
bool getShouldReaverage() const { return _shouldReaverage; }
|
||||||
|
|
||||||
void recurseNodeWithOperation(OctreeElement* node, RecurseOctreeOperation operation,
|
void recurseNodeWithOperation(OctreeElement* node, RecurseOctreeOperation operation,
|
||||||
void* extraData, int recursionCount = 0);
|
void* extraData, int recursionCount = 0);
|
||||||
|
|
||||||
void recurseNodeWithOperationDistanceSorted(OctreeElement* node, RecurseOctreeOperation operation,
|
void recurseNodeWithOperationDistanceSorted(OctreeElement* node, RecurseOctreeOperation operation,
|
||||||
const glm::vec3& point, void* extraData, int recursionCount = 0);
|
const glm::vec3& point, void* extraData, int recursionCount = 0);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -269,7 +269,7 @@ public slots:
|
||||||
protected:
|
protected:
|
||||||
void deleteOctalCodeFromTreeRecursion(OctreeElement* node, void* extraData);
|
void deleteOctalCodeFromTreeRecursion(OctreeElement* node, void* extraData);
|
||||||
|
|
||||||
int encodeTreeBitstreamRecursion(OctreeElement* node,
|
int encodeTreeBitstreamRecursion(OctreeElement* node,
|
||||||
OctreePacketData* packetData, OctreeElementBag& bag,
|
OctreePacketData* packetData, OctreeElementBag& bag,
|
||||||
EncodeBitstreamParams& params, int& currentEncodeLevel) const;
|
EncodeBitstreamParams& params, int& currentEncodeLevel) const;
|
||||||
|
|
||||||
|
@ -277,20 +277,20 @@ protected:
|
||||||
|
|
||||||
OctreeElement* nodeForOctalCode(OctreeElement* ancestorNode, const unsigned char* needleCode, OctreeElement** parentOfFoundNode) const;
|
OctreeElement* nodeForOctalCode(OctreeElement* ancestorNode, const unsigned char* needleCode, OctreeElement** parentOfFoundNode) const;
|
||||||
OctreeElement* createMissingNode(OctreeElement* lastParentNode, const unsigned char* codeToReach);
|
OctreeElement* createMissingNode(OctreeElement* lastParentNode, const unsigned char* codeToReach);
|
||||||
int readNodeData(OctreeElement *destinationNode, const unsigned char* nodeData,
|
int readNodeData(OctreeElement *destinationNode, const unsigned char* nodeData,
|
||||||
int bufferSizeBytes, ReadBitstreamToTreeParams& args);
|
int bufferSizeBytes, ReadBitstreamToTreeParams& args);
|
||||||
|
|
||||||
OctreeElement* _rootNode;
|
OctreeElement* _rootNode;
|
||||||
|
|
||||||
bool _isDirty;
|
bool _isDirty;
|
||||||
bool _shouldReaverage;
|
bool _shouldReaverage;
|
||||||
bool _stopImport;
|
bool _stopImport;
|
||||||
|
|
||||||
/// Octal Codes of any subtrees currently being encoded. While any of these codes is being encoded, ancestors and
|
/// Octal Codes of any subtrees currently being encoded. While any of these codes is being encoded, ancestors and
|
||||||
/// descendants of them can not be deleted.
|
/// descendants of them can not be deleted.
|
||||||
std::set<const unsigned char*> _codesBeingEncoded;
|
std::set<const unsigned char*> _codesBeingEncoded;
|
||||||
/// mutex lock to protect the encoding set
|
/// mutex lock to protect the encoding set
|
||||||
pthread_mutex_t _encodeSetLock;
|
QMutex _encodeSetLock;
|
||||||
|
|
||||||
/// Called to indicate that a OctreeElement is in the process of being encoded.
|
/// Called to indicate that a OctreeElement is in the process of being encoded.
|
||||||
void startEncoding(OctreeElement* node);
|
void startEncoding(OctreeElement* node);
|
||||||
|
@ -299,11 +299,11 @@ protected:
|
||||||
/// Is the Octal Code currently being deleted?
|
/// Is the Octal Code currently being deleted?
|
||||||
bool isEncoding(const unsigned char* codeBuffer);
|
bool isEncoding(const unsigned char* codeBuffer);
|
||||||
|
|
||||||
/// Octal Codes of any subtrees currently being deleted. While any of these codes is being deleted, ancestors and
|
/// Octal Codes of any subtrees currently being deleted. While any of these codes is being deleted, ancestors and
|
||||||
/// descendants of them can not be encoded.
|
/// descendants of them can not be encoded.
|
||||||
std::set<const unsigned char*> _codesBeingDeleted;
|
std::set<const unsigned char*> _codesBeingDeleted;
|
||||||
/// mutex lock to protect the deleting set
|
/// mutex lock to protect the deleting set
|
||||||
pthread_mutex_t _deleteSetLock;
|
QMutex _deleteSetLock;
|
||||||
|
|
||||||
/// Called to indicate that an octal code is in the process of being deleted.
|
/// Called to indicate that an octal code is in the process of being deleted.
|
||||||
void startDeleting(const unsigned char* code);
|
void startDeleting(const unsigned char* code);
|
||||||
|
@ -313,13 +313,13 @@ protected:
|
||||||
/// instead queued for later delete
|
/// instead queued for later delete
|
||||||
std::set<const unsigned char*> _codesPendingDelete;
|
std::set<const unsigned char*> _codesPendingDelete;
|
||||||
/// mutex lock to protect the deleting set
|
/// mutex lock to protect the deleting set
|
||||||
pthread_mutex_t _deletePendingSetLock;
|
QMutex _deletePendingSetLock;
|
||||||
|
|
||||||
/// Adds an Octal Code to the set of codes that needs to be deleted
|
/// Adds an Octal Code to the set of codes that needs to be deleted
|
||||||
void queueForLaterDelete(const unsigned char* codeBuffer);
|
void queueForLaterDelete(const unsigned char* codeBuffer);
|
||||||
/// flushes out any Octal Codes that had to be queued
|
/// flushes out any Octal Codes that had to be queued
|
||||||
void emptyDeleteQueue();
|
void emptyDeleteQueue();
|
||||||
|
|
||||||
QReadWriteLock lock;
|
QReadWriteLock lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,10 @@ GenericThread::GenericThread() :
|
||||||
_stopThread(false),
|
_stopThread(false),
|
||||||
_isThreaded(false) // assume non-threaded, must call initialize()
|
_isThreaded(false) // assume non-threaded, must call initialize()
|
||||||
{
|
{
|
||||||
pthread_mutex_init(&_mutex, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericThread::~GenericThread() {
|
GenericThread::~GenericThread() {
|
||||||
terminate();
|
terminate();
|
||||||
pthread_mutex_destroy(&_mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericThread::initialize(bool isThreaded) {
|
void GenericThread::initialize(bool isThreaded) {
|
||||||
|
@ -32,30 +30,30 @@ void GenericThread::initialize(bool isThreaded) {
|
||||||
void GenericThread::terminate() {
|
void GenericThread::terminate() {
|
||||||
if (_isThreaded) {
|
if (_isThreaded) {
|
||||||
_stopThread = true;
|
_stopThread = true;
|
||||||
pthread_join(_thread, NULL);
|
pthread_join(_thread, NULL);
|
||||||
_isThreaded = false;
|
_isThreaded = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void* GenericThread::threadRoutine() {
|
void* GenericThread::threadRoutine() {
|
||||||
while (!_stopThread) {
|
while (!_stopThread) {
|
||||||
|
|
||||||
// override this function to do whatever your class actually does, return false to exit thread early
|
// override this function to do whatever your class actually does, return false to exit thread early
|
||||||
if (!process()) {
|
if (!process()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// In non-threaded mode, this will break each time you call it so it's the
|
// In non-threaded mode, this will break each time you call it so it's the
|
||||||
// callers responsibility to continuously call this method
|
// callers responsibility to continuously call this method
|
||||||
if (!_isThreaded) {
|
if (!_isThreaded) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isThreaded) {
|
if (_isThreaded) {
|
||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void* GenericThreadEntry(void* arg) {
|
extern "C" void* GenericThreadEntry(void* arg) {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#define __shared__GenericThread__
|
#define __shared__GenericThread__
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
@ -41,15 +42,15 @@ public:
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/// Locks all the resources of the thread.
|
/// Locks all the resources of the thread.
|
||||||
void lock() { pthread_mutex_lock(&_mutex); }
|
void lock() { _mutex.lock(); }
|
||||||
|
|
||||||
/// Unlocks all the resources of the thread.
|
/// Unlocks all the resources of the thread.
|
||||||
void unlock() { pthread_mutex_unlock(&_mutex); }
|
void unlock() { _mutex.unlock(); }
|
||||||
|
|
||||||
bool isStillRunning() const { return !_stopThread; }
|
bool isStillRunning() const { return !_stopThread; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
pthread_mutex_t _mutex;
|
QMutex _mutex;
|
||||||
|
|
||||||
bool _stopThread;
|
bool _stopThread;
|
||||||
bool _isThreaded;
|
bool _isThreaded;
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <pthread.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -35,7 +34,6 @@ Node::Node(const QUuid& uuid, char type, const HifiSockAddr& publicSocket, const
|
||||||
_isAlive(true),
|
_isAlive(true),
|
||||||
_clockSkewUsec(0)
|
_clockSkewUsec(0)
|
||||||
{
|
{
|
||||||
pthread_mutex_init(&_mutex, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Node::~Node() {
|
Node::~Node() {
|
||||||
|
@ -44,8 +42,6 @@ Node::~Node() {
|
||||||
}
|
}
|
||||||
|
|
||||||
delete _bytesReceivedMovingAverage;
|
delete _bytesReceivedMovingAverage;
|
||||||
|
|
||||||
pthread_mutex_destroy(&_mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Names of Node Types
|
// Names of Node Types
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QUuid>
|
#include <QtCore/QUuid>
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
#include "HifiSockAddr.h"
|
#include "HifiSockAddr.h"
|
||||||
#include "NodeData.h"
|
#include "NodeData.h"
|
||||||
|
@ -29,39 +30,39 @@ class Node {
|
||||||
public:
|
public:
|
||||||
Node(const QUuid& uuid, char type, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket);
|
Node(const QUuid& uuid, char type, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket);
|
||||||
~Node();
|
~Node();
|
||||||
|
|
||||||
bool operator==(const Node& otherNode) const { return _uuid == otherNode._uuid; }
|
bool operator==(const Node& otherNode) const { return _uuid == otherNode._uuid; }
|
||||||
bool operator!=(const Node& otherNode) const { return !(*this == otherNode); }
|
bool operator!=(const Node& otherNode) const { return !(*this == otherNode); }
|
||||||
|
|
||||||
char getType() const { return _type; }
|
char getType() const { return _type; }
|
||||||
void setType(char type) { _type = type; }
|
void setType(char type) { _type = type; }
|
||||||
const char* getTypeName() const;
|
const char* getTypeName() const;
|
||||||
|
|
||||||
const QUuid& getUUID() const { return _uuid; }
|
const QUuid& getUUID() const { return _uuid; }
|
||||||
void setUUID(const QUuid& uuid) { _uuid = uuid; }
|
void setUUID(const QUuid& uuid) { _uuid = uuid; }
|
||||||
|
|
||||||
uint64_t getWakeMicrostamp() const { return _wakeMicrostamp; }
|
uint64_t getWakeMicrostamp() const { return _wakeMicrostamp; }
|
||||||
void setWakeMicrostamp(uint64_t wakeMicrostamp) { _wakeMicrostamp = wakeMicrostamp; }
|
void setWakeMicrostamp(uint64_t wakeMicrostamp) { _wakeMicrostamp = wakeMicrostamp; }
|
||||||
|
|
||||||
uint64_t getLastHeardMicrostamp() const { return _lastHeardMicrostamp; }
|
uint64_t getLastHeardMicrostamp() const { return _lastHeardMicrostamp; }
|
||||||
void setLastHeardMicrostamp(uint64_t lastHeardMicrostamp) { _lastHeardMicrostamp = lastHeardMicrostamp; }
|
void setLastHeardMicrostamp(uint64_t lastHeardMicrostamp) { _lastHeardMicrostamp = lastHeardMicrostamp; }
|
||||||
|
|
||||||
const HifiSockAddr& getPublicSocket() const { return _publicSocket; }
|
const HifiSockAddr& getPublicSocket() const { return _publicSocket; }
|
||||||
void setPublicSocket(const HifiSockAddr& publicSocket);
|
void setPublicSocket(const HifiSockAddr& publicSocket);
|
||||||
const HifiSockAddr& getLocalSocket() const { return _localSocket; }
|
const HifiSockAddr& getLocalSocket() const { return _localSocket; }
|
||||||
void setLocalSocket(const HifiSockAddr& localSocket);
|
void setLocalSocket(const HifiSockAddr& localSocket);
|
||||||
|
|
||||||
const HifiSockAddr* getActiveSocket() const { return _activeSocket; }
|
const HifiSockAddr* getActiveSocket() const { return _activeSocket; }
|
||||||
|
|
||||||
void activatePublicSocket();
|
void activatePublicSocket();
|
||||||
void activateLocalSocket();
|
void activateLocalSocket();
|
||||||
|
|
||||||
NodeData* getLinkedData() const { return _linkedData; }
|
NodeData* getLinkedData() const { return _linkedData; }
|
||||||
void setLinkedData(NodeData* linkedData) { _linkedData = linkedData; }
|
void setLinkedData(NodeData* linkedData) { _linkedData = linkedData; }
|
||||||
|
|
||||||
bool isAlive() const { return _isAlive; }
|
bool isAlive() const { return _isAlive; }
|
||||||
void setAlive(bool isAlive) { _isAlive = isAlive; }
|
void setAlive(bool isAlive) { _isAlive = isAlive; }
|
||||||
|
|
||||||
void recordBytesReceived(int bytesReceived);
|
void recordBytesReceived(int bytesReceived);
|
||||||
float getAverageKilobitsPerSecond();
|
float getAverageKilobitsPerSecond();
|
||||||
float getAveragePacketsPerSecond();
|
float getAveragePacketsPerSecond();
|
||||||
|
@ -71,20 +72,20 @@ public:
|
||||||
|
|
||||||
int getClockSkewUsec() const { return _clockSkewUsec; }
|
int getClockSkewUsec() const { return _clockSkewUsec; }
|
||||||
void setClockSkewUsec(int clockSkew) { _clockSkewUsec = clockSkew; }
|
void setClockSkewUsec(int clockSkew) { _clockSkewUsec = clockSkew; }
|
||||||
|
|
||||||
void lock() { pthread_mutex_lock(&_mutex); }
|
void lock() { _mutex.lock(); }
|
||||||
|
|
||||||
/// returns false if lock failed, true if you got the lock
|
/// returns false if lock failed, true if you got the lock
|
||||||
bool trylock() { return (pthread_mutex_trylock(&_mutex) == 0); }
|
bool trylock() { return _mutex.tryLock(); }
|
||||||
void unlock() { pthread_mutex_unlock(&_mutex); }
|
void unlock() { _mutex.unlock(); }
|
||||||
|
|
||||||
static void printLog(Node const&);
|
static void printLog(Node const&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// privatize copy and assignment operator to disallow Node copying
|
// privatize copy and assignment operator to disallow Node copying
|
||||||
Node(const Node &otherNode);
|
Node(const Node &otherNode);
|
||||||
Node& operator=(Node otherNode);
|
Node& operator=(Node otherNode);
|
||||||
|
|
||||||
char _type;
|
char _type;
|
||||||
QUuid _uuid;
|
QUuid _uuid;
|
||||||
uint64_t _wakeMicrostamp;
|
uint64_t _wakeMicrostamp;
|
||||||
|
@ -97,7 +98,7 @@ private:
|
||||||
bool _isAlive;
|
bool _isAlive;
|
||||||
int _pingMs;
|
int _pingMs;
|
||||||
int _clockSkewUsec;
|
int _clockSkewUsec;
|
||||||
pthread_mutex_t _mutex;
|
QMutex _mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
int unpackNodeId(unsigned char *packedData, uint16_t *nodeId);
|
int unpackNodeId(unsigned char *packedData, uint16_t *nodeId);
|
||||||
|
|
Loading…
Reference in a new issue