• <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++ 基礎} {C++ 高級} {C#界面,C++核心算法} {設計模式} {C#基礎}

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

            c++的多線程編程


            由于現在的標準c++庫中沒有對多線程的支持,所以如果我們想使用多線程,就是使用其他的庫支持。


            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)多核程序設計技術——通過軟件多線程提升性能(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)很不錯的文檔下載: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 夢在天涯 閱讀(12014) 評論(1)  編輯 收藏 引用 所屬分類: CPlusPlus

            評論

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

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

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

              回復  更多評論   

            公告

            EMail:itech001#126.com

            導航

            統計

            • 隨筆 - 461
            • 文章 - 4
            • 評論 - 746
            • 引用 - 0

            常用鏈接

            隨筆分類

            隨筆檔案

            收藏夾

            Blogs

            c#(csharp)

            C++(cpp)

            Enlish

            Forums(bbs)

            My self

            Often go

            Useful Webs

            Xml/Uml/html

            搜索

            •  

            積分與排名

            • 積分 - 1804159
            • 排名 - 5

            最新評論

            閱讀排行榜

            97r久久精品国产99国产精| 国产一区二区精品久久凹凸| 国产69精品久久久久APP下载| 97精品依人久久久大香线蕉97| 国产精品久久久久jk制服| 青青热久久综合网伊人| 久久无码高潮喷水| 成人资源影音先锋久久资源网| 午夜精品久久影院蜜桃| 国产精品免费看久久久| 久久久久久久久久久免费精品| 无码AV中文字幕久久专区| 久久久精品久久久久久| 久久国产热精品波多野结衣AV| 久久性精品| 97精品国产97久久久久久免费| 一本久久a久久精品亚洲| 欧美久久久久久精选9999| 久久中文字幕一区二区| 久久亚洲国产成人精品性色 | 久久婷婷五月综合国产尤物app | 久久综合丁香激情久久| 亚洲国产美女精品久久久久∴| 久久久久亚洲AV成人网人人网站 | 色综合久久无码五十路人妻| 一本久道久久综合狠狠躁AV| 色综合久久综精品| 久久综合久久综合久久| 国产成人精品久久二区二区| 久久国产精品99精品国产| 久久久久99精品成人片直播| 亚洲精品乱码久久久久久久久久久久| 久久久黄片| 久久人妻AV中文字幕| 精品久久久一二三区| 久久亚洲日韩看片无码| 久久综合九色综合网站| 亚洲va中文字幕无码久久| 久久99国产综合精品女同| jizzjizz国产精品久久| 中文精品久久久久国产网址|