Beispiel #1
0
        public ScriptContext CreateContext()
        {
            // _rwlock.EnterWriteLock();
            ScriptContextRef freeEntry;
            int slotIndex;

            if (_freeContextSlot < 0)
            {
                freeEntry = new ScriptContextRef();
                slotIndex = _contextRefs.Count;
                _contextRefs.Add(freeEntry);
                freeEntry.next = -1;
            }
            else
            {
                slotIndex        = _freeContextSlot;
                freeEntry        = _contextRefs[slotIndex];
                _freeContextSlot = freeEntry.next;
                freeEntry.next   = -1;
            }

            var context = new ScriptContext(this, slotIndex + 1);

            freeEntry.target   = context;
            context.OnDestroy += OnContextDestroy;

            if (_mainContext == null)
            {
                _mainContext = context;
            }
            // _rwlock.ExitWriteLock();

            context.RegisterBuiltins();
            return(context);
        }
Beispiel #2
0
        public ScriptContext CreateContext()
        {
            var context = new ScriptContext(this);

            _contexts.Add(context);
            context.OnDestroy += OnContextDestroy;
            context.RegisterBuiltins();
            return(context);
        }