0

スレッドビルディングブロック(http://threadingbuildingblocks.org/ver.php?fid=174)をディレクトリ/ home / is_admin /tbb40_233oss/のcentosにインストールします

これは私のコードです:

#include "tbb/concurrent_queue.h" 
#include <iostream> 
using namespace std; 
using namespace tbb; 
int main() { 
    concurrent_queue<int> queue; 
    for( int i=0; i<10; ++i ) 
        queue.push(i); 
    for( concurrent_queue<int>::const_iterator i(queue.begin()); 
i!=queue.end(); ++i ) 
        cout << *i << " "; 
    cout << endl; 
    return 0; 
}

このコマンドを使用してコードをコンパイルします。

g++ test_concurrent_queue.cpp -I/home/is_admin/tbb40_233od/linux_intel64_gcc_cc4.1.2_libc2.5_kernel2.6.18_release -ltbb -o tcq

しかし、それはこのエラーを与えます:

class tbb::strict_ppl::concurrent_queue<int, tbb::cache_aligned_allocator<int> > has no member named begin

class tbb::strict_ppl::concurrent_queue<int, tbb::cache_aligned_allocator<int> > has no member named end

理由がわかりませんか?tbbの経験がある人は誰でも私を助けることができますか?

4

1 に答える 1

2

編集:

使用したドキュメントは古く、では機能しなくなりましたconcurrent_queue。私の答えの残りはまだ立っています。


またはメソッド concurrent_queueがないため:http: //threadingbuildingblocks.org/files/documentation/a00134.htmlbeginend

キューが複数のスレッドで使用されていない場合にのみ使用する必要があるため、このように名前が付けられunsafe_beginたメソッドとメソッドがあります(つまり、マルチスレッド環境での使用は安全ではありません)。unsafe_end

キューを実行する一般的な方法は、キューが空になるまで要素をポップすることです。

int i;
while(queue.try_pop(i)) // as long as you can pop, pop.
    cout << i << " "; 
于 2012-04-19T06:11:27.153 に答える