예제 #1
0
    public void ForEachParallel(Vector2i v0, Vector2i v1, Vector2i v2, Action <int, int> action)
    {
        int      num1     = Mathx.Min((int)v0.x, (int)v1.x, (int)v2.x);
        int      num2     = Mathx.Max((int)v0.x, (int)v1.x, (int)v2.x);
        int      num3     = Mathx.Min((int)v0.y, (int)v1.y, (int)v2.y);
        int      num4     = Mathx.Max((int)v0.y, (int)v1.y, (int)v2.y);
        Vector2i base_min = new Vector2i(num1, num3);
        Vector2i vector2i;

        ((Vector2i) ref vector2i).\u002Ector(num2, num4);
        Vector2i base_count = Vector2i.op_Addition(Vector2i.op_Subtraction(vector2i, base_min), (Vector2i)Vector2i.one);

        Parallel.Call((Action <int, int>)((thread_id, thread_count) => this.ForEachInternal(v0, v1, v2, action, Vector2i.op_Addition(base_min, Vector2i.op_Division(Vector2i.op_Multiply(base_count, thread_id), thread_count)), Vector2i.op_Subtraction(Vector2i.op_Addition(base_min, Vector2i.op_Division(Vector2i.op_Multiply(base_count, thread_id + 1), thread_count)), (Vector2i)Vector2i.one))));
    }
예제 #2
0
    public void ForEachParallel(Vector2i v0, Vector2i v1, Vector2i v2, Action <int, int> action)
    {
        int      num       = Mathx.Min(v0.x, v1.x, v2.x);
        int      num1      = Mathx.Max(v0.x, v1.x, v2.x);
        int      num2      = Mathx.Min(v0.y, v1.y, v2.y);
        int      num3      = Mathx.Max(v0.y, v1.y, v2.y);
        Vector2i vector2i1 = new Vector2i(num, num2);
        Vector2i vector2i2 = new Vector2i(num1, num3);
        Vector2i vector2i3 = (vector2i2 - vector2i1) + Vector2i.one;

        Parallel.Call((int thread_id, int thread_count) => {
            Vector2i baseMin  = vector2i1 + ((vector2i3 * thread_id) / thread_count);
            Vector2i vector2i = (vector2i1 + ((vector2i3 * (thread_id + 1)) / thread_count)) - Vector2i.one;
            this.ForEachInternal(v0, v1, v2, action, baseMin, vector2i);
        });
    }