just::thread Support Forum

General Category => General Discussion about just::thread => Topic started by: sodapop on March 04, 2014, 05:34:47 PM

Title: Serialization of jss::concurrent_map
Post by: sodapop 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?
Title: Re: Serialization of jss::concurrent_map
Post by: Anthony Williams 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.