Author Topic: Serialization of jss::concurrent_map  (Read 53075 times)

sodapop

  • Newbie
  • *
  • Posts: 8
    • View Profile
Serialization of jss::concurrent_map
« on: March 04, 2014, 05:34:47 PM »
Is there anyone on the forums who knows how to serialize a jss::concurrent_map? Are there any built in functions to do this?

Anthony Williams

  • Administrator
  • Full Member
  • *****
  • Posts: 103
    • View Profile
    • just::thread C++ Thread Library
Re: Serialization of jss::concurrent_map
« Reply #1 on: March 04, 2014, 05:55:07 PM »
Is there anyone on the forums who knows how to serialize a jss::concurrent_map? Are there any built in functions to do this?

By "serialize", I assume you mean write out to a stream. No, there are no functions supplied to do this. You could use the iteration interface:

Code: [Select]
jss::concurrent_map<int,unsigned> map;
for(jss::concurrent_map<int,unsigned>::iterator it=map.begin(),end=map.end();it!=end;++it){
    std::cout<<it->first<<":"<<it->second<<std::endl;
}

Of course, if another thread modifies the map in the mean time then you may or may not see their modifications.