Exemple #1
0
        public ObjectCache(ObjectCacheFunc func, object user_data, int ttl)
        {
            this.func        = func;
            this.user_data   = user_data;
            this.initial_ttl = this.ttl = ttl;
            this.id          = ++next_id;

            mutex.Lock();
            objects.Add(this);
            mutex.Unlock();
        }
Exemple #2
0
        // <summary>
        //   Stop all currently running threads without sending any notifications.
        //   The threads are automatically resumed to their previos state when
        //   ReleaseGlobalThreadLock() is called.
        // </summary>
        internal void AcquireGlobalThreadLock(SingleSteppingEngine caller)
        {
            if (has_thread_lock)
            {
                throw new InternalError("Recursive thread lock");
            }

            thread_lock_mutex.Lock();
            Report.Debug(DebugFlags.Threads,
                         "Acquiring global thread lock: {0}", caller);
            has_thread_lock = true;
            foreach (ThreadServant thread in thread_hash.Values)
            {
                if (thread == caller)
                {
                    continue;
                }
                thread.AcquireThreadLock();
            }
            Report.Debug(DebugFlags.Threads,
                         "Done acquiring global thread lock: {0}",
                         caller);
        }