• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            C++ Programmer's Cookbook

            {C++ 基礎(chǔ)} {C++ 高級(jí)} {C#界面,C++核心算法} {設(shè)計(jì)模式} {C#基礎(chǔ)}

            c++的多線程編程(資料收集)

            c++的多線程編程


            由于現(xiàn)在的標(biāo)準(zhǔn)c++庫中沒有對(duì)多線程的支持,所以如果我們想使用多線程,就是使用其他的庫支持。


            1)使用windows提供的多線程支持

              中文msdn中查找多線程編程,可以找到。
              http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/vccore/html/_core_multithreading_with_c_and_win32.asp

            2)使用MFC提供多線程支持

              中文msdn中查找多線程編程,可以找到。
            http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/vccore/html/_core_multithreading_with_c_and_win32.asp

            3)使用boost提供的多線程

            http://www.boost.org/doc/html/threads.html


            4)多核程序設(shè)計(jì)技術(shù)——通過軟件多線程提升性能(intel出的書)


            5)codeproject上C++下的多線程

            6) windows核心編程

            7)intel :http://shareit.intel.com/WikiHome/Articles/111111287

            8)intel:http://shareit.intel.com/WikiHome/Articles/111111284

            9)很不錯(cuò)的文檔下載:http://www.intel.com/cd/ids/developer/asmo-na/eng/dc/threading/knowledgebase/20439.htm

            10)msdn上所有的線程同步API介紹:http://msdn2.microsoft.com/en-us/library/ms686360.aspx


            線程同步API:(來自msdn)

             
            Asynchronous function Description
            APCProc An application-defined callback function used with the QueueUserAPC function.
            GetOverlappedResult Retrieves the results of an overlapped operation.
            QueueUserAPC Adds a user-mode asynchronous procedure call (APC) object to the APC queue of the specified thread.

            Condition variable and SRW lock function Description
            AcquireSRWLockExclusive Acquires a slim reader/writer (SRW) lock in exclusive mode.
            AcquireSRWLockShared Acquires a slim reader/writer (SRW) lock in shared mode.
            InitializeConditionVariable Initializes a condition variable.
            InitializeSRWLock Initialize a slim reader/writer (SRW) lock.
            ReleaseSRWLockExclusive Releases a slim reader/writer (SRW) lock that was acquired in exclusive mode.
            ReleaseSRWLockShared Releases a slim reader/writer (SRW) lock that was acquired in shared mode.
            SleepConditionVariableCS Sleeps on the specified condition variable and releases the specified critical section as an atomic operation.
            SleepConditionVariableSRW Sleeps on the specified condition variable and releases the specified lock as an atomic operation.
            WakeAllConditionVariable Wake all threads waiting on the specified condition variable.
            WakeConditionVariable Wake a single thread waiting on the specified condition variable.

            Critical-section function Description
            DeleteCriticalSection Releases all resources used by an unowned critical section object.
            EnterCriticalSection Waits for ownership of the specified critical section object.
            InitializeCriticalSection Initializes a critical section object.
            InitializeCriticalSectionAndSpinCount Initializes a critical section object and sets the spin count for the critical section.
            InitializeCriticalSectionEx Initializes a critical section object with a spin count and optional flags.
            LeaveCriticalSection Releases ownership of the specified critical section object.
            SetCriticalSectionSpinCount Sets the spin count for the specified critical section.
            TryEnterCriticalSection Attempts to enter a critical section without blocking.

            Event function Description
            CreateEvent Creates or opens a named or unnamed event object.
            CreateEventEx Creates or opens a named or unnamed event object and returns a handle to the object.
            OpenEvent Opens an existing named event object.
            PulseEvent Sets the specified event object to the signaled state and then resets it to the nonsignaled state after releasing the appropriate number of waiting threads.
            ResetEvent Sets the specified event object to the nonsignaled state.
            SetEvent Sets the specified event object to the signaled state.

            One-time Initialization function Description
            InitOnceBeginInitialize Begins one-time initialization.
            InitOnceComplete Completes one-time initialization.
            InitOnceExecuteOnce Executes the specified function successfully one time. No other threads that specify the same one-time initialization structure can execute this function while it is being executed by the current thread.
            InitOnceInitialize Initializes a one-time initialization structure.

            Interlocked function Description
            InterlockedAdd Performs an atomic addition operation on the specified LONG values.
            InterlockedAdd64 Performs an atomic addition operation on the specified LONGLONG values.
            InterlockedAddAcquire Performs an atomic addition operation on the specified LONG values. The operation is performed with acquire memory access semantics.
            InterlockedAddAcquire64 Performs an atomic addition operation on the specified LONGLONG values. The operation is performed with acquire memory access semantics.
            InterlockedAddRelease Performs an atomic addition operation on the specified LONG values. The operation is performed with release memory access semantics.
            InterlockedAddRelease64 Performs an atomic addition operation on the specified LONGLONG values. The operation is performed with release memory access semantics.
            InterlockedAnd Performs an atomic AND operation on the specified LONG values.
            InterlockedAndAcquire Performs an atomic AND operation on the specified LONG values. The operation is performed with acquire memory access semantics.
            InterlockedAndRelease Performs an atomic AND operation on the specified LONG values. The operation is performed with release memory access semantics.
            InterlockedAnd8 Performs an atomic AND operation on the specified char values.
            InterlockedAnd8Acquire Performs an atomic AND operation on the specified char values. The operation is performed with acquire memory access semantics.
            InterlockedAnd8Release Performs an atomic AND operation on the specified char values. The operation is performed with release memory access semantics.
            InterlockedAnd16 Performs an atomic AND operation on the specified SHORT values.
            InterlockedAnd16Acquire Performs an atomic AND operation on the specified SHORT values. The operation is performed with acquire memory access semantics.
            InterlockedAnd16Release Performs an atomic AND operation on the specified SHORT values. The operation is performed with release memory access semantics.
            InterlockedAnd64 Performs an atomic AND operation on the specified LONGLONG values.
            InterlockedAnd64Acquire Performs an atomic AND operation on the specified LONGLONG values. The operation is performed with acquire memory access semantics.
            InterlockedAnd64Release Performs an atomic AND operation on the specified LONGLONG values. The operation is performed with release memory access semantics.
            InterlockedBitTestAndReset Tests the specified bit of the specified LONG value and sets it to 0.
            InterlockedBitTestAndReset64 Tests the specified bit of the specified LONG64 value and sets it to 0.
            InterlockedBitTestAndSet Tests the specified bit of the specified LONG value and sets it to 1.
            InterlockedBitTestAndSet64 Tests the specified bit of the specified LONG64 value and sets it to 1.
            InterlockedCompare64Exchange128 Performs an atomic compare-and-exchange operation on the specified values. The function compares the specified 64-bit values and exchanges with the specified 128-bit value based on the outcome of the comparison.
            InterlockedCompare64ExchangeAcquire128 Performs an atomic compare-and-exchange operation on the specified values. The function compares the specified 64-bit values and exchanges with the specified 128-bit value based on the outcome of the comparison. The operation is performed with acquire memory access semantics.
            InterlockedCompare64ExchangeRelease128 Performs an atomic compare-and-exchange operation on the specified values. The function compares the specified 64-bit values and exchanges with the specified 128-bit value based on the outcome of the comparison. The operation is performed with release memory access semantics.
            InterlockedCompareExchange Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 32-bit values and exchanges with another 32-bit value based on the outcome of the comparison.
            InterlockedCompareExchange64 Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 64-bit values and exchanges with another 64-bit value based on the outcome of the comparison.
            InterlockedCompareExchangeAcquire Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 32-bit values and exchanges with another 32-bit value based on the outcome of the comparison. The operation is performed with acquire memory access semantics.
            InterlockedCompareExchangeAcquire64 Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 64-bit values and exchanges with another 64-bit value based on the outcome of the comparison. The exchange is performed with acquire memory access semantics.
            InterlockedCompareExchangePointer Performs an atomic compare-and-exchange operation on the specified pointer values. The function compares two specified pointer values and exchanges with another pointer value based on the outcome of the comparison.
            InterlockedCompareExchangePointerAcquire Performs an atomic compare-and-exchange operation on the specified pointer values. The function compares two specified pointer values and exchanges with another pointer value based on the outcome of the comparison. The operation is performed with acquire memory access semantics.
            InterlockedCompareExchangePointerRelease Performs an atomic compare-and-exchange operation on the specified pointer values. The function compares two specified pointer values and exchanges with another pointer value based on the outcome of the comparison. The operation is performed with release memory access semantics.
            InterlockedCompareExchangeRelease Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 32-bit values and exchanges with another 32-bit value based on the outcome of the comparison. The exchange is performed with release memory access semantics.
            InterlockedCompareExchangeRelease64 Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 64-bit values and exchanges with another 64-bit value based on the outcome of the comparison. The exchange is performed with release memory access semantics.
            InterlockedDecrement Decrements (decreases by one) the value of the specified 32-bit variable as an atomic operation.
            InterlockedDecrement64 Decrements (decreases by one) the value of the specified 64-bit variable as an atomic operation.
            InterlockedDecrementAcquire Decrements (decreases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed with acquire memory access semantics.
            InterlockedDecrementAcquire64 Decrements (decreases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed with acquire memory access semantics.
            InterlockedDecrementRelease Decrements (decreases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed with release memory access semantics.
            InterlockedDecrementRelease64 Decrements (decreases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed with release memory access semantics.
            InterlockedExchange Sets a 32-bit variable to the specified value as an atomic operation.
            InterlockedExchange64 Sets a 64-bit variable to the specified value as an atomic operation.
            InterlockedExchangeAcquire Sets a 32-bit variable to the specified value as an atomic operation. The operation is performed with acquire memory access semantics.
            InterlockedExchangeAcquire64 Sets a 32-bit variable to the specified value as an atomic operation. The operation is performed with acquire memory access semantics.
            InterlockedExchangeAdd Performs an atomic addition of two 32-bit values.
            InterlockedExchangeAdd64 Performs an atomic addition of two 64-bit values.
            InterlockedExchangeAddAcquire Performs an atomic addition of two 32-bit values. The operation is performed with acquire memory access semantics.
            InterlockedExchangeAddAcquire64 Performs an atomic addition of two 64-bit values. The operation is performed with acquire memory access semantics.
            InterlockedExchangeAddRelease Performs an atomic addition of two 32-bit values. The operation is performed with release memory access semantics.
            InterlockedExchangeAddRelease64 Performs an atomic addition of two 64-bit values. The operation is performed with release memory access semantics.
            InterlockedExchangePointer Atomically exchanges a pair of pointer values.
            InterlockedExchangePointerAcquire Atomically exchanges a pair of pointer values. The operation is performed with acquire memory access semantics.
            InterlockedIncrement Increments (increases by one) the value of the specified 32-bit variable as an atomic operation.
            InterlockedIncrement64 Increments (increases by one) the value of the specified 64-bit variable as an atomic operation.
            InterlockedIncrementAcquire Increments (increases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed using acquire memory access semantics.
            InterlockedIncrementAcquire64 Increments (increases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed using acquire memory access semantics.
            InterlockedIncrementRelease Increments (increases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed using release memory access semantics.
            InterlockedIncrementRelease64 Increments (increases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed using release memory access semantics.
            InterlockedOr Performs an atomic OR operation on the specified LONG values.
            InterlockedOrAcquire Performs an atomic OR operation on the specified LONG values. The operation is performed with acquire memory access semantics.
            InterlockedOrRelease Performs an atomic OR operation on the specified LONG values. The operation is performed with release memory access semantics.
            InterlockedOr8 Performs an atomic OR operation on the specified char values.
            InterlockedOr8Acquire Performs an atomic OR operation on the specified char values. The operation is performed with acquire memory access semantics.
            InterlockedOr8Release Performs an atomic OR operation on the specified char values. The operation is performed with release memory access semantics.
            InterlockedOr16 Performs an atomic OR operation on the specified SHORT values.
            InterlockedOr16Acquire Performs an atomic OR operation on the specified SHORT values. The operation is performed with acquire memory access semantics.
            InterlockedOr16Release Performs an atomic OR operation on the specified SHORT values. The operation is performed with release memory access semantics.
            InterlockedOr64 Performs an atomic OR operation on the specified LONGLONG values.
            InterlockedOr64Acquire Performs an atomic OR operation on the specified LONGLONG values. The operation is performed with acquire memory access semantics.
            InterlockedOr64Release Performs an atomic OR operation on the specified LONGLONG values. The operation is performed with release memory access semantics.
            InterlockedXor Performs an atomic XOR operation on the specified LONG values.
            InterlockedXorAcquire Performs an atomic XOR operation on the specified LONG values. The operation is performed with acquire memory access semantics.
            InterlockedXorRelease Performs an atomic XOR operation on the specified LONG values. The operation is performed with release memory access semantics.
            InterlockedXor8 Performs an atomic XOR operation on the specified char values.
            InterlockedXor8Acquire Performs an atomic XOR operation on the specified char values. The operation is performed with acquire memory access semantics.
            InterlockedXor8Release Performs an atomic XOR operation on the specified char values. The operation is performed with release memory access semantics.
            InterlockedXor16 Performs an atomic XOR operation on the specified SHORT values.
            InterlockedXor16Acquire Performs an atomic XOR operation on the specified SHORT values. The operation is performed with acquire memory access semantics.
            InterlockedXor16Release Performs an atomic XOR operation on the specified SHORT values. The operation is performed with release memory access semantics.
            InterlockedXor64 Performs an atomic XOR operation on the specified LONGLONG values.
            InterlockedXor64Acquire Performs an atomic XOR operation on the specified LONGLONG values. The operation is performed with acquire memory access semantics.
            InterlockedXor64Release Performs an atomic XOR operation on the specified LONGLONG values. The operation is performed with release memory access semantics.

            Mutex function Description
            CreateMutex Creates or opens a named or unnamed mutex object.
            CreateMutexEx Creates or opens a named or unnamed mutex object and returns a handle to the object.
            OpenMutex Opens an existing named mutex object.
            ReleaseMutex Releases ownership of the specified mutex object.

            Namespace function Description
            AddSIDToBoundaryDescriptor Adds a new security identifier (SID) to the specified boundary descriptor.
            ClosePrivateNamespace Closes an open namespace handle.
            CreateBoundaryDescriptor Creates a boundary descriptor.
            CreatePrivateNamespace Creates a private namespace.
            DeleteBoundaryDescriptor Deletes the specified boundary descriptor.
            OpenPrivateNamespace Opens a private namespace.

            Semaphore function Description
            CreateSemaphore Creates or opens a named or unnamed semaphore object.
            CreateSemaphoreEx Creates or opens a named or unnamed semaphore object and returns a handle to the object.
            OpenSemaphore Opens an existing named semaphore object.
            ReleaseSemaphore Increases the count of the specified semaphore object by a specified amount.

            Singly-linked list function Description
            InitializeSListHead Initializes the head of a singly linked list.
            InterlockedFlushSList Flushes the entire list of items in a singly linked list.
            InterlockedPopEntrySList Removes an item from the front of a singly linked list.
            InterlockedPushEntrySList Inserts an item at the front of a singly linked list.
            QueryDepthSList Retrieves the number of entries in the specified singly linked list.
            RtlFirstEntrySList Retrieves the first entry in a singly linked list.
            RtlInitializeSListHead Initializes the head of a singly linked list. Applications should call InitializeSListHead instead.
            RtlInterlockedFlushSList Flushes the entire list of items in a singly linked list. Applications should call InterlockedFlushSList instead.
            RtlInterlockedPopEntrySList Removes an item from the front of a singly linked list. Applications should call InterlockedPopEntrySList instead.
            RtlInterlockedPushEntrySList Inserts an item at the front of a singly linked list. Applications should call InterlockedPushEntrySList instead.
            RtlQueryDepthSList Retrieves the number of entries in the specified singly linked list. Applications should call QueryDepthSList instead.

            Timer-queue timer function Description
            ChangeTimerQueueTimer Updates a timer-queue timer.
            CreateTimerQueue Creates a queue for timers.
            CreateTimerQueueTimer Creates a timer-queue timer.
            DeleteTimerQueue Deletes a timer queue.
            DeleteTimerQueueEx Deletes a timer queue.
            DeleteTimerQueueTimer Cancels a timer-queue timer.

            Wait function Description
            MsgWaitForMultipleObjects Waits until one or all of the specified objects are in the signaled state or the time-out interval elapses. The objects can include input event objects.
            MsgWaitForMultipleObjectsEx Waits until one or all of the specified objects are in the signaled state, an I/O completion routine or asynchronous procedure call (APC) is queued to the thread, or the time-out interval elapses. The array of objects can include input event objects.
            RegisterWaitForSingleObject Directs a wait thread in the thread pool to wait on the object.
            SignalObjectAndWait Atomically signals one object and waits on another object.
            UnregisterWait Cancels a registered wait operation.
            UnregisterWaitEx Cancels a registered wait operation.
            WaitForMultipleObjects Waits until one or all of the specified objects are in the signaled state or the time-out interval elapses.
            WaitForMultipleObjectsEx Waits until one or all of the specified objects are in the signaled state, an I/O completion routine or asynchronous procedure call (APC) is queued to the thread, or the time-out interval elapses.
            WaitForSingleObject Waits until the specified object is in the signaled state or the time-out interval elapses.
            WaitForSingleObjectEx Waits until the specified object is in the signaled state, an I/O completion routine or asynchronous procedure call (APC) is queued to the thread, or the time-out interval elapses.
            WaitOrTimerCallback An application-defined function that serves as the starting address for a timer callback or a registered wait callback.

            Waitable-timer function Description
            CancelWaitableTimer Sets the specified waitable timer to the inactive state.
            CreateWaitableTimer Creates or opens a waitable timer object.
            CreateWaitableTimerEx Creates or opens a waitable timer object and returns a handle to the object.
            OpenWaitableTimer Opens an existing named waitable timer object.
            SetWaitableTimer Activates the specified waitable timer.
            TimerAPCProc Application-defined timer completion routine used with the SetWaitableTimer function.


            posted on 2007-03-16 17:12 夢(mèng)在天涯 閱讀(12014) 評(píng)論(1)  編輯 收藏 引用 所屬分類: CPlusPlus

            評(píng)論

            # re: c++的多線程編程(資料收集) 2007-03-17 08:52 Galaxy_Yang

            最近的工作中遇到了多線程的問題,
            就是http異步多線程下載, 總是有一個(gè)線程獲得的CPU的時(shí)間不多,
            其他線程都結(jié)束了, 整個(gè)文件的下載過程得等最后一個(gè)線程下完才行,不知道
            flashget和thunder是怎么做到基本上多個(gè)線程是同時(shí)結(jié)束的?

            想和你探討以下多線程編程的問題

              回復(fù)  更多評(píng)論   

            公告

            EMail:itech001#126.com

            導(dǎo)航

            統(tǒng)計(jì)

            • 隨筆 - 461
            • 文章 - 4
            • 評(píng)論 - 746
            • 引用 - 0

            常用鏈接

            隨筆分類

            隨筆檔案

            收藏夾

            Blogs

            c#(csharp)

            C++(cpp)

            Enlish

            Forums(bbs)

            My self

            Often go

            Useful Webs

            Xml/Uml/html

            搜索

            •  

            積分與排名

            • 積分 - 1804314
            • 排名 - 5

            最新評(píng)論

            閱讀排行榜

            日韩精品无码久久一区二区三 | 精品久久久一二三区| 伊人久久大香线蕉av一区| 久久久久夜夜夜精品国产| 亚洲欧美久久久久9999| 久久亚洲国产午夜精品理论片| 久久香综合精品久久伊人| 国产AⅤ精品一区二区三区久久| 亚洲中文字幕无码久久精品1 | 精品国产综合区久久久久久| 亚洲va中文字幕无码久久| 老司机午夜网站国内精品久久久久久久久| 久久精品国产99久久久古代| 色偷偷88888欧美精品久久久| 久久久久亚洲AV无码专区网站| 久久se精品一区精品二区| 国产毛片欧美毛片久久久| 三级片免费观看久久| 国产福利电影一区二区三区,免费久久久久久久精 | 久久精品一区二区三区中文字幕| 久久久久免费看成人影片| 久久久久久久波多野结衣高潮| 久久久久国产| 国产一区二区精品久久岳| 伊人久久综在合线亚洲2019| 亚洲欧美日韩久久精品第一区| 国产精品久久久久久久久软件 | 久久精品国产精品亚洲| 亚洲午夜久久久精品影院| 久久91精品国产91久久麻豆| 99精品国产在热久久无毒不卡 | 久久综合综合久久狠狠狠97色88| 精品熟女少妇av免费久久| 久久精品人人做人人妻人人玩| 无码超乳爆乳中文字幕久久| 人妻精品久久久久中文字幕69| 国内精品久久久久久中文字幕| 精品多毛少妇人妻AV免费久久| 久久精品亚洲精品国产欧美| 久久久精品波多野结衣| 亚洲国产高清精品线久久|