diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index a5fc32881f..16bd5256f8 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -24,8 +24,8 @@ Agent::Agent(const unsigned char* dataBuffer, int numBytes) : ThreadedAssignment(dataBuffer, numBytes) { - _particleScriptingInterface.init(); - _voxelScriptingInterface.init(); + //_particleScriptingInterface.init(); + //_voxelScriptingInterface.init(); } void Agent::processDatagram(const QByteArray& dataByteArray, const HifiSockAddr& senderSockAddr) { @@ -34,12 +34,12 @@ void Agent::processDatagram(const QByteArray& dataByteArray, const HifiSockAddr& // PACKET_TYPE_JURISDICTION, first byte is the node type... switch (dataByteArray[headerBytes]) { case NODE_TYPE_VOXEL_SERVER: - _voxelScriptingInterface.getJurisdictionListener()->queueReceivedPacket(senderSockAddr, + _scriptEngine.getVoxelScriptingInterface()->getJurisdictionListener()->queueReceivedPacket(senderSockAddr, (unsigned char*) dataByteArray.data(), dataByteArray.size()); break; case NODE_TYPE_PARTICLE_SERVER: - _particleScriptingInterface.getJurisdictionListener()->queueReceivedPacket(senderSockAddr, + _scriptEngine.getParticleScriptingInterface()->getJurisdictionListener()->queueReceivedPacket(senderSockAddr, (unsigned char*) dataByteArray.data(), dataByteArray.size()); break; @@ -94,10 +94,10 @@ void Agent::run() { connect(pingNodesTimer, SIGNAL(timeout()), nodeList, SLOT(pingInactiveNodes())); pingNodesTimer->start(PING_INACTIVE_NODE_INTERVAL_USECS / 1000); - const unsigned int VISUAL_DATA_CALLBACK_USECS = (1.0 / 60.0) * 1000 * 1000; + //const unsigned int VISUAL_DATA_CALLBACK_USECS = (1.0 / 60.0) * 1000 * 1000; // let the VoxelPacketSender know how frequently we plan to call it - _voxelScriptingInterface.getVoxelPacketSender()->setProcessCallIntervalHint(VISUAL_DATA_CALLBACK_USECS); - _particleScriptingInterface.getParticlePacketSender()->setProcessCallIntervalHint(VISUAL_DATA_CALLBACK_USECS); + //_voxelScriptingInterface.getVoxelPacketSender()->setProcessCallIntervalHint(VISUAL_DATA_CALLBACK_USECS); + //_particleScriptingInterface.getParticlePacketSender()->setProcessCallIntervalHint(VISUAL_DATA_CALLBACK_USECS); _scriptEngine.setScriptContents(scriptContents); diff --git a/assignment-client/src/Agent.h b/assignment-client/src/Agent.h index e6e7eb84b1..8f77141a30 100644 --- a/assignment-client/src/Agent.h +++ b/assignment-client/src/Agent.h @@ -34,8 +34,8 @@ signals: void willSendAudioDataCallback(); void willSendVisualDataCallback(); private: - VoxelScriptingInterface _voxelScriptingInterface; - ParticleScriptingInterface _particleScriptingInterface; + //VoxelScriptingInterface _voxelScriptingInterface; + //ParticleScriptingInterface _particleScriptingInterface; ScriptEngine _scriptEngine; }; diff --git a/libraries/scriptengine/src/ScriptEngine.cpp b/libraries/scriptengine/src/ScriptEngine.cpp index 7d34a4edf6..3bffa35929 100644 --- a/libraries/scriptengine/src/ScriptEngine.cpp +++ b/libraries/scriptengine/src/ScriptEngine.cpp @@ -116,16 +116,14 @@ void ScriptEngine::run() { if (usecToSleep > 0) { usleep(usecToSleep); } - + if (_isFinished) { - //qDebug() << "line: " << __LINE__ << " _isFinished... breaking loop\n"; break; } QCoreApplication::processEvents(); if (_isFinished) { - //qDebug() << "line: " << __LINE__ << " _isFinished... breaking loop\n"; break; } @@ -138,7 +136,9 @@ void ScriptEngine::run() { _voxelScriptingInterface.getVoxelPacketSender()->releaseQueuedMessages(); // since we're in non-threaded mode, call process so that the packets are sent - //_voxelScriptingInterface.getVoxelPacketSender()->process(); + if (!_voxelScriptingInterface.getVoxelPacketSender()->isThreaded()) { + _voxelScriptingInterface.getVoxelPacketSender()->process(); + } } if (_particleScriptingInterface.getParticlePacketSender()->serversExist()) { @@ -149,14 +149,15 @@ void ScriptEngine::run() { _particleScriptingInterface.getParticlePacketSender()->releaseQueuedMessages(); // since we're in non-threaded mode, call process so that the packets are sent - //_particleScriptingInterface.getParticlePacketSender()->process(); + if (!_particleScriptingInterface.getParticlePacketSender()->isThreaded()) { + _particleScriptingInterface.getParticlePacketSender()->process(); + } } if (willSendVisualDataCallBack) { emit willSendVisualDataCallback(); } - if (engine.hasUncaughtException()) { int line = engine.uncaughtExceptionLineNumber(); qDebug() << "Uncaught exception at line" << line << ":" << engine.uncaughtException().toString() << "\n"; @@ -177,3 +178,4 @@ void ScriptEngine::stop() { _isFinished = true; } + diff --git a/libraries/shared/src/GenericThread.h b/libraries/shared/src/GenericThread.h index 013b7a7936..2de9112204 100644 --- a/libraries/shared/src/GenericThread.h +++ b/libraries/shared/src/GenericThread.h @@ -33,6 +33,8 @@ public: /// Override this function to do whatever your class actually does, return false to exit thread early. virtual bool process() = 0; + bool isThreaded() const { return _isThreaded; } + protected: /// Locks all the resources of the thread. @@ -43,8 +45,6 @@ protected: bool isStillRunning() const { return !_stopThread; } - bool isThreaded() const { return _isThreaded; } - private: pthread_mutex_t _mutex;