Example #1
0
 /// <summary>
 /// Should only be called by the LSL api as it directly accesses the scripts
 /// </summary>
 /// <param name="itemID"></param>
 /// <returns></returns>
 public bool GetScriptState(OpenMetaverse.UUID itemID)
 {
     VM.Interpreter script = _exeScheduler.FindScript(itemID);
     if (script == null)
     {
         return(false);
     }
     return(script.ScriptState.Enabled);
 }
Example #2
0
        public float GetAverageScriptTime(UUID itemID)
        {
            VM.Interpreter script = _exeScheduler.FindScript(itemID);
            if (script != null)
            {
                return(script.GetAverageScriptTime());
            }

            return(0.0f);
        }
Example #3
0
        public int GetUsedMemory(UUID itemID)
        {
            VM.Interpreter script = _exeScheduler.FindScript(itemID);
            if (script != null)
            {
                return(script.ScriptState.MemInfo.MemoryUsed);
            }

            return(0);
        }
Example #4
0
        /// <summary>
        /// Can only be called from inside the script run thread as it directly accesses script data
        /// </summary>
        /// <param name="itemID"></param>
        /// <returns></returns>
        public float GetTotalRuntime(UUID itemID)
        {
            VM.Interpreter script = _exeScheduler.FindScript(itemID);
            if (script != null)
            {
                return(script.ScriptState.TotalRuntime);
            }

            return(0.0f);
        }
Example #5
0
 public void ScriptChanged(VM.Interpreter script)
 {
     lock (_scriptChangeLock)
     {
         _dirtyScripts[script.ItemId] = script;
         if (!_delayQueue.ContainsKey(script.ItemId))
         {
             _delayQueue.Add(script.ItemId, DateTime.Now + SAVE_INTERVAL);
             _scheduler.RequestStateData(new StateDataRequest(script.ItemId, this.StateAvailable));
         }
     }
 }
Example #6
0
        /// <summary>
        /// Can only be called from inside the script run thread as it directly accesses script data
        /// Returns the amount of free space in the event queue (0 - 1.0)
        /// </summary>
        /// <param name="itemID"></param>
        /// <returns></returns>
        public float GetEventQueueFreeSpacePercentage(UUID itemID)
        {
            VM.Interpreter script = _exeScheduler.FindScript(itemID);
            if (script == null)
            {
                return(1.0f);
            }

            if (script.ScriptState.EventQueue.Count >= VM.RuntimeState.MAX_EVENT_QUEUE_SIZE)
            {
                return(0.0f); // No space
            }
            else
            {
                return(1.0f - (float)script.ScriptState.EventQueue.Count / VM.RuntimeState.MAX_EVENT_QUEUE_SIZE);
            }
        }
        // Returns true if it found the script loaded and decremented the refcount.
        private bool PerformUnloadRequest(LoadUnloadRequest unloadReq)
        {
            bool rc = false;

            // Find based on the item ID
            VM.Interpreter loadedScript = _exeScheduler.FindScript(unloadReq.ItemId);

            if (loadedScript != null)
            {
                LoadedScript reffedScript;

                //tell the scheduler the script needs to be pulled
                _exeScheduler.DoUnload(unloadReq.ItemId, unloadReq);

                //tell the async command manager that it needs to remove this script
                AsyncCommandManager.RemoveScript(_engineInterface, unloadReq.LocalId, unloadReq.ItemId);

                //tell the state manager to remove this script
                _stateManager.ScriptUnloaded(unloadReq.ItemId);

                //decref and unload if refcount is 0 based on the Asset ID
                if (_loadedScripts.TryGetValue(loadedScript.Script.AssetId, out reffedScript))
                {
                    if (--reffedScript.RefCount == 0)
                    {
                        _loadedScripts.Remove(loadedScript.Script.AssetId);
                        _unloadedScriptCache.Add(loadedScript.Script.AssetId, loadedScript.Script);
                    }

                    rc = true;
                }
            }

            // Callback here because if the Item ID was not found, the callback would be meaningless
            if (unloadReq.PostUnloadCallback != null)
            {
                // Now call the completion callback (e.g. now that it is safe for the script to be removed in the delete case).
                unloadReq.PostUnloadCallback(unloadReq.Prim, unloadReq.ItemId, unloadReq.CallbackParams.AllowedDrop, unloadReq.CallbackParams.FireEvents, unloadReq.CallbackParams.ReplaceArgs);
            }

            return(rc);
        }