upgrade_to_unique_lock doesn't compile with vc2010

Using Boost 1.43, this program:
# include

Braden McDaniel
Using Boost 1.43, this program:
# include
int main() { boost::shared_mutex mutex; boost::upgrade_lockboost::shared_mutex lock(mutex); boost::upgrade_to_unique_lockboost::shared_mutex write_lock(lock); }
... produces this error when compiled with Visual C++ 2010:
That is trac issue 2501. It was fixed post 1.43, so should be in 1.44. Anthony -- Author of C++ Concurrency in Action http://www.stdthread.co.uk/book/ just::thread C++0x thread library http://www.stdthread.co.uk Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

Hi
How could I loop through the container to get all the keys.
Eg:
For(int i=0;i< beambook.count();++i)
Or
Beambook:: iter1 = beambook.begin(), iter2 = beambook.end();
My requirement is to loop through the size and list compositeKey vs list
of element Ids
Thanks,
UJ
// define a multi_index_container with a composite key on
typedef multi_index_container<
Beam_entry,
indexed_by<
//non-unique as some might have more than ids
ordered_non_unique<
composite_key<
Beam_entry,
member
beambook;

On Tuesday, June 01, 2010 5:41 AM, Uthpal Urubail wrote:
Hi How could I loop through the container to get all the keys. Eg: For(int i=0;i< beambook.count();++i) Or Beambook:: iter1 = beambook.begin(), iter2 = beambook.end();
My requirement is to loop through the size and list compositeKey vs list of element Ids
Thanks, UJ
// define a multi_index_container with a composite key on typedef multi_index_container< Beam_entry, indexed_by< //non-unique as some might have more than ids ordered_non_unique< composite_key< Beam_entry, member
, member , member , member , member , member > >, ordered_unique< member > > beambook;
for (beambook::iterator iter = container.begin(), i_end = container.end(); iter != i_end; iter = container.upper_bound (get key from iter))

Thanks for the reply..
Let me put my requirement more clear.
I want to loop through and get all the element Ids[ member
Hi How could I loop through the container to get all the keys. Eg: For(int i=0;i< beambook.count();++i) Or Beambook:: iter1 = beambook.begin(), iter2 = beambook.end();
My requirement is to loop through the size and list compositeKey vs list of element Ids
Thanks, UJ
// define a multi_index_container with a composite key on typedef multi_index_container< Beam_entry, indexed_by< //non-unique as some might have more than ids ordered_non_unique< composite_key< Beam_entry, member
, member , member , member , member , member > >, ordered_unique< member > > beambook;
for (beambook::iterator iter = container.begin(), i_end = container.end(); iter != i_end; iter = container.upper_bound (get key from iter)) _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Uthpal Urubail escribió:
Thanks for the reply.. Let me put my requirement more clear. I want to loop through and get all the element Ids[ member
] which are having the same member values[pid, orientX, orientY, orientZ, OffsetA and OffsetB]. I am expecting the count of the container to give the count of unique member entries.
I think this is what you're after: for(beambook::iterator iter=pb.begin(),i_end=pb.end();iter!=i_end;){ beambook::iterator iter_next=pb.upper_bound(pb.key_extractor()(*iter)); // the bunch of elements in [iter,iter_next) have the same // [pid,orientX,orientX,orientZ,OffsetA,OffsetB] do{ // print eid or whatever }while(++iter!=iter_next); } Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Hi
I am looking for a composite key container.
Though I found multi_index_container for composite key is the best I
have few doubts in its use case:
Question:01
class Book
{
public:
size_t mID;
size_t node[3];
};
How to add the below into multi_index_container?
typedef multi_index_container<
Book,
indexed_by<
ordered_unique<
composite_key<
Book,
member
beambook;
Question:02 My requirement is straight forward. I need to get the id by providing 3 nodes. Should I always need to create a data structure? [class Book] Can't I have something like below? typedef multi_index_container< size_t, indexed_by< ordered_unique< composite_key< size_t, size_t, size_t > >, ordered_unique< size_t > >
beambook;
Thanks, UJ

Uthpal Urubail escribió:
Hi
I am looking for a composite key container.
Though I found multi_index_container for composite key is the best I have few doubts in its use case:
*Question:01*
class Book
{
public:
size_t mID;
*size_t node[3];*
};
How to add the below into multi_index_container?
typedef multi_index_container<
Book,
indexed_by<
ordered_unique<
composite_key<
Book,
member
, member
, member
>
>,
ordered_unique<
member
>
>
beambook;
member
beambook;
*Question:02*
My requirement is straight forward. I need to get the id by providing 3 nodes.
Should I always need to create a data structure? [class Book]
No, in fact you don't need to create a Book object. Suppose bb is a beambook and you want to retrieve the mID of an element in bb with nodes n0, n1 and n2. You only have to do the following: size_t mID=bb.find(boost::make_tuple(n0,n1,n2))->mID; As you can see, you simply pass a tuple with the values for the composite key, not a whole Book object. Hope this helps, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Joaquín M López Muñoz,
Thanks for offering me the help.
One interesting observation:
If I use the below in finding the objects it is not retrieving properly
indexed_by<
ordered_unique< /// INSTEAD if I use ordered_non_unique< it works fine
composite_key<
I am still not clear with my question:2
Can I define the container like below?
I don't want to create the temporary data structure. I will get these information from a class object. Can I use them directly??
Please help me in understanding.
typedef multi_index_container<
Hi
I am looking for a composite key container.
Though I found multi_index_container for composite key is the best I have few doubts in its use case:
*Question:01*
class Book
{
public:
size_t mID;
*size_t node[3];*
};
How to add the below into multi_index_container?
typedef multi_index_container<
Book,
indexed_by<
ordered_unique<
composite_key<
Book,
member
, member
, member
>
>,
ordered_unique<
member
>
>
beambook;
member
beambook;
*Question:02*
My requirement is straight forward. I need to get the id by providing 3 nodes.
Should I always need to create a data structure? [class Book]
No, in fact you don't need to create a Book object. Suppose bb is a beambook and you want to retrieve the mID of an element in bb with nodes n0, n1 and n2. You only have to do the following: size_t mID=bb.find(boost::make_tuple(n0,n1,n2))->mID; As you can see, you simply pass a tuple with the values for the composite key, not a whole Book object. Hope this helps, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Uthpal Urubail escribió:
Joaquín M López Muñoz, Thanks for offering me the help.
You're welcome. Please don't top-post and try to follow the general discussion policies outlined at http://www.boost.org/community/policy.html
One interesting observation: If I use the below in finding the objects it is not retrieving properly indexed_by< ordered_unique< /// INSTEAD if I use ordered_non_unique< it works fine composite_key<
If you use ordered_unique then there cannot be two elements with the same node[0], node[1], node[2] values. I guess this is what's happening in your case.
I am still not clear with my question:2 Can I define the container like below? I don't want to create the temporary data structure. I will get these information from a class object. Can I use them directly?? Please help me in understanding.
typedef multi_index_container<
, //?? indexed_by< ordered_unique< composite_key< , //??? BookNodeExtractor<0>, BookNodeExtractor<1>, BookNodeExtractor<2> > >, ordered_unique< member > > beambook;
I'm not sure what your question is, but if you wonder whether you can define a container of pointers to Books rather than Book objects proper, the answer is: you can, but you have to modify BookNodeExtractor so that it accepts pointers rather than Book &s. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Joaquín,
My question is:
Can I define container like below?
typedef multi_index_container<
ElemShell*,
indexed_by<
//non-unique as some might have more than ids
ordered_non_unique<
composite_key<
ElemShell*,
member
beambook;
When I retrieve, beambook::iterator it=(pb.find(boost::make_tuple(obj->N1,obj->N2,obj->N3,node4))); int val = (*it)->N4; Application is crashing. About: If you use ordered_unique then there cannot be two elements with the same node[0], node[1], node[2] values. Its TRUE. Two elements cannot have same node[0], node[1], node[2] values. How should be the container? Thanks, Uthpal

Uthpal Urubail escribió:
Joaquín, My question is: Can I define container like below? typedef multi_index_container< ElemShell*, indexed_by< //non-unique as some might have more than ids ordered_non_unique< composite_key< ElemShell*, member
, member , member , member > >, ordered_unique< member > > beambook;
Yes, you can (except that the second index seems to be wrongly keyed on GeneralElement rather than ElemShell, but I understand this is a typo.)
When I retrieve, beambook::iterator it=(pb.find(boost::make_tuple(obj->N1,obj->N2,obj->N3,node4))); int val = (*it)->N4; Application is crashing.
Almost surely because there's no element with the provided N1,N2,N3,N4 and hence the iteraror it is pb.end().
About: If you use ordered_unique then there cannot be two elements with the same node[0], node[1], node[2] values. Its TRUE. Two elements cannot have same node[0], node[1], node[2] values. How should be the container?
Use ordered_unique then, as your own statements imply. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Hi I am new to multithreading please help me to resolve the below issue. I am getting the below error when I try to compile a simple multithreading program. 'libboost_thread-vc80-mt-gd-1_41.lib' - Is missing in boost installation. [**folder $BOOST_ROOT/stage is missing] 1>------ Build started: Project: BoostMultithreading, Configuration: Debug Win32 ------ 1>Compiling... 1>main.cpp 1>Linking... 1>LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc80-mt-gd-1_41.lib' 1>BoostMultithreading - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Thanks in advance UJ

AMDG Uthpal Urubail wrote:
I am new to multithreading please help me to resolve the below issue. I am getting the below error when I try to compile a simple multithreading program. 'libboost_thread-vc80-mt-gd-1_41.lib' - Is missing in boost installation. [**folder $BOOST_ROOT/stage is missing]
1>------ Build started: Project: BoostMultithreading, Configuration: Debug Win32 ------ 1>Compiling... 1>main.cpp 1>Linking... 1>LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc80-mt-gd-1_41.lib' 1>BoostMultithreading - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Have you read http://www.boost.org/more/getting_started/windows.html? In Christ, Steven Watanabe P.S. Please start a new thread instead of replying to an unrelated thread.

On Tue, 2010-06-01 at 07:48 +0100, Anthony Williams wrote:
Braden McDaniel
writes: Using Boost 1.43, this program:
# include
int main() { boost::shared_mutex mutex; boost::upgrade_lockboost::shared_mutex lock(mutex); boost::upgrade_to_unique_lockboost::shared_mutex write_lock(lock); }
... produces this error when compiled with Visual C++ 2010:
That is trac issue 2501. It was fixed post 1.43, so should be in 1.44.
Aha. Thanks.
--
Braden McDaniel

Hello, That is trac issue 2501. It was fixed post 1.43, so should be in 1.44.
Trunk version of locks.hpp does not compile this example with MSVC 2010. Do I need other files from trunk to fix this issue? I've attached patch that I did to fix this issue for me. (Should be applied to trunk version of locks.hpp) Best Regards, Sergei
participants (7)
-
Andrew Holden
-
Anthony Williams
-
Braden McDaniel
-
joaquin@tid.es
-
Sergei Politov
-
Steven Watanabe
-
Uthpal Urubail