static int get_PoolScheduler(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            LuaFramework.ThreadManager obj = (LuaFramework.ThreadManager)o;
            Frankfort.Threading.ThreadPoolScheduler ret = obj.PoolScheduler;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index PoolScheduler on a nil value"));
        }
    }
    void Start()
    {
        myScheduler = Loom.CreateThreadPoolScheduler("myScheduler");

        displayTexture = new Texture2D(Texture.width, Texture.height, TextureFormat.ARGB32, false);
        textureWidth = Texture.width;
        textureHeight = Texture.height;

        origionalColors = Texture.GetPixels32();
        sourcePixels = new Pixel[origionalColors.Length];
        sourceColors = new Color32[origionalColors.Length];
        destinationColors = new Color32[origionalColors.Length];

        int i =0;
        for (int y = 0; y < Texture.height; y++)
        {
            for (int x = 0; x < Texture.width; x++)
            {
                sourcePixels[i] = new Pixel(x, y);
                i++;
            }
        }

        myScheduler.ForceToMainThread = !MultithreadingEnabled;
        StartBluringTexture();
    }
示例#3
0
 public NetWorkManager()
 {
     MaxThreads = -1;
     m_Client = new NetClient ();
     m_SendMsgs = new Queue<SendMsg>();
     m_Client.JoinServerCompleteHandler = OnJoinServerComplete;
     m_Client.LeaveServerHandler = OnLeaveServer;
     m_Client.ReceivedUserMessageHandler = OnReceiveUserMessage;
     m_Client.P2PMemberJoinHandler = OnP2PMemberJoin;
     m_Client.P2PMemberLeaveHandler = OnP2PMemberLeave;
     Loom.StartSingleThread(SendMessages, System.Threading.ThreadPriority.Normal, false);
     myScheduler = Loom.CreateThreadPoolScheduler("myScheduler");
     myScheduler.ForceToMainThread = false;
 }
    private void InitThreadPool()
    {
        //--------------- Cap the number of threads --------------------
        int maxThreads = ThreadingMaxThreads;
        if (maxThreads <= 0)
            maxThreads = Mathf.Max(SystemInfo.processorCount - 1, 1);
        //--------------- Cap the number of threads --------------------

        //--------------- Spread the Flocks over multiple worker-packages --------------------
        int ThreadingPoolPackages = ThreadingPackagesPerThread * maxThreads;

        int flocksPerBlock = Mathf.CeilToInt((float)FlockingSpawnCount / (float)ThreadingPoolPackages);
        workerObjects = new FlockingDataWorker[ThreadingPoolPackages];

        int i = ThreadingPoolPackages;
        int startIdx = 0;
        while (--i > -1)
        {
            FlockingDataWorker workerBlock = new FlockingDataWorker();
            UpdateWorkerObjectStats(workerBlock);

            workerBlock.startWorkIndex = startIdx;
            workerBlock.endWorkIndex = Mathf.Min(flockers.Length, startIdx + flocksPerBlock);
            workerObjects[i] = workerBlock;
            startIdx += flocksPerBlock;
        }
        //--------------- Spread the Flocks over multiple worker-packages --------------------

        myThreadScheduler = Loom.CreateThreadPoolScheduler();
        myThreadScheduler.ForceToMainThread = !MultithreadingEnabled;
        myThreadScheduler.StartASyncThreads(workerObjects, onThreadWorkComplete, null, maxThreads);
    }
示例#5
0
 void Awake()
 {
     myScheduler = Loom.CreateThreadPoolScheduler("myScheduler");
     myScheduler.ForceToMainThread = true;
     _LGO = new GameObject("_LGO");
     _LGO.AddComponent<netLoop>();
     _RGO = new GameObject("_RGO");
     _RGO.AddComponent<netLoop>();
     DontDestroyOnLoad(_LGO);
     DontDestroyOnLoad(_RGO);
     InitCore(EventHandler);
     DontDestroyOnLoad(this);
     DontDestroyOnLoad(login);
     DontDestroyOnLoad(pass);
     DontDestroyOnLoad(GameObject.Find("InfoLabel"));
 }
    void Awake()
    {
        Application.targetFrameRate = 25;
        myThreadScheduler = Loom.CreateThreadPoolScheduler();

        //--------------- Ending Single threaded routine --------------------
        threadA = Loom.StartSingleThread(EndingSingleThreadCoroutine, System.Threading.ThreadPriority.Normal, true);
        //--------------- Ending Single threaded routine --------------------

        //--------------- Continues Single threaded routine --------------------
        threadB = Loom.StartSingleThread(ContinuesSingleThreadCoroutine, System.Threading.ThreadPriority.Normal, true);
        //--------------- Continues Single threaded routine --------------------

        //--------------- Start Multithreaded packages --------------------
        int i = TestWorkerObjects;
        IThreadWorkerObject[] workerObjects = new IThreadWorkerObject[TestWorkerObjects];

        while (--i > -1)
            workerObjects[i] = new LotsOfNumbers(UnityEngine.Random.Range(minCalculations, maxCalculations));

        myThreadScheduler.StartASyncThreads(workerObjects, OnThreadWorkComplete, OnWorkerObjectDone, maxThreads);
        StartCoroutine(AbortAllThreadsAfterDelay());
        //--------------- Start Multithreaded packages --------------------
    }