realizedchore.h

来自「C语言库函数的原型,有用的拿去」· C头文件 代码 · 共 71 行

H
71
字号
// ==++==
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// ==--==
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
//
// chore.h
//
// Header file containing the realized chore type declaration.
//
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#pragma once

namespace Concurrency
{
namespace details
{

    /// <summary>
    ///     The class RealizedChore is used to implement light-weight tasks and Agents.
    /// </summary>

    class RealizedChore : public _Chore
    {

    public:

        /// <summary>
        ///     Constructor.
        /// </summary>
        RealizedChore(TaskProc pFunction, void* pParameters)
        {
            Initialize(pFunction, pParameters);
        }

        /// <summary>
        ///     Initializes a realized chore, on construction and reuse.
        /// </summary>
        void Initialize(TaskProc pFunction, void* pParameters)
        {
            m_pFunction = pFunction;
            m_pParameters = pParameters;
            m_pNext = NULL;
        }

        /// <summary>
        ///     Method that executes the realized chore.
        /// </summary>
        __declspec(noinline)
        void Invoke();

    private:
        template <typename T> friend class SQueue;
        template <class T> friend class LockFreeStack;

        // Parameter to the chore procedure.
        void *m_pParameters;

        union
        {
            // Next pointer for the locked runnables queue.
            RealizedChore *m_pNext;

            // List entry for lock free slist (free pool)
            SLIST_ENTRY m_slNext;
        };
    };
} // namespace details
} // namespace Concurrency

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?