Exemple #1
0
        private unsafe void ContinueWorker(int threadId, Guid guid)
        {
            Native32.AffinitizeThreadRoundRobin((uint)threadId);

            Empty context;

            var success = inputArrays.TryTake(out Input[] inputArray);

            if (!success)
            {
                Console.WriteLine("No input array for {0}", threadId);
                return;
            }

            // Register thread with the store
            var startNum = fht.ContinueSession(guid);

            Interlocked.Increment(ref numActiveThreads);

            Console.WriteLine("Thread {0} starting from {1}", threadId, startNum + 1);

            // Prpcess the batch of input data
            fixed(Input *input = inputArray)
            {
                for (long i = startNum + 1; i < numOps; i++)
                {
                    fht.RMW(&((input + i)->adId), input + i, &context, i);

                    if ((i + 1) % checkpointInterval == 0 && numActiveThreads == threadCount)
                    {
                        if (fht.TakeFullCheckpoint(out Guid token))
                        {
                            Console.WriteLine("Calling TakeCheckpoint");
                        }
                    }

                    if (i % completePendingInterval == 0)
                    {
                        fht.CompletePending(false);
                    }
                    else if (i % refreshInterval == 0)
                    {
                        fht.Refresh();
                    }
                }
            }

            // Make sure operations are completed
            fht.CompletePending(true);

            // Deregister thread from FASTER
            fht.StopSession();

            //Interlocked.Decrement(ref numActiveThreads);

            Console.WriteLine("Populate successful on thread {0}", threadId);
        }