- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I was trying to make a class HashArray, which will act as an "envelope" for the tbb::concurrent_hash_map.
However, I have problems with the accessor and the iterators of the concurrent map.
It seems that the accessors in DoSomething() are not recognised, as well as the iterator in GatherStats().
Here's the code:
Thanks!
I was trying to make a class HashArray, which will act as an "envelope" for the tbb::concurrent_hash_map.
However, I have problems with the accessor and the iterators of the concurrent map.
It seems that the accessors in DoSomething() are not recognised, as well as the iterator in GatherStats().
Here's the code:
[cpp]#ifndef TBB_HashArray_h
#define TBB_HashArray_h
#include "tbb/concurrent_hash_map.h"
#include
namespace mcl {
template
struct HashCompare {
static size_t hash( const K& key ) {
return tbb::tbb_hasher(key);
}
static bool equal( const K& key1, const K& key2 ) {
return ( key1 == key2 );
}
};
template
class HashArray {
private:
static unsigned int initial_hash_size;
tbb::concurrent_hash_map> h;
HashArray(const HashArray& S);
const HashArray& operator=(const HashArray& S);
public:
HashArray(): h(initial_hash_size) {}
~HashArray() {}
bool DoSomething(const K& key) {
tbb::concurrent_hash_map>::accessor a;
h.insert(a,key);
return true;
}
const bool DoSomething (const K& key) const {
tbb::concurrent_hash_map>::const_accessor a;
h.insert(a,key);
return true;
}
bool IsDefined(const K key) const { return h.count(key)!=0; }
void UnDefine(const K key) { h.erase(key); }
void GatherStats() const {
tbb::concurrent_hash_map>::const_iterator it = h.begin();
while ( it != h.end() ) {
//std::cout << ((*it).second).size() << std::endl;
++it;
}
}
void Clear(void) { h.clear(); }
void Resize(void) { h.clear(); }
};
template
unsigned int HashArray::initial_hash_size=1000;
}
#endif[/cpp]
Thanks!
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi again,
it seems that the problem is the use of templates. If I use
it seems that the problem is the use of templates. If I use
tbb::concurrent_hash_map>::accessor a
when compiling I get an error: error: expected `;' before a
However, if for example I write
However, if for example I write
tbb::concurrent_hash_map<:STRING>>::accessor a
when compiling that error disappears.
But I need to use templates... any idea? I'm in blank.
Thanks!
when compiling that error disappears.
But I need to use templates... any idea? I'm in blank.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
try to write:
tbb::template concurrent_hash_map>::const_accessora;
or
tbb::template concurrent_hash_map>::const_accessora;
or
typename tbb::template concurrent_hash_map>::const_accessora;
or
typename tbb::template concurrent_hash_map>::const_accessora;
tbb::template concurrent_hash_map
or
tbb::template concurrent_hash_map
or
typename tbb::template concurrent_hash_map
or
typename tbb::template concurrent_hash_map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes. It worked well with typename.
Thanks ilnarb.
Thanks ilnarb.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page