Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #5684

Re: std::ifstream multithread

From Philipp Kraus <philipp.kraus@flashpixx.de>
Newsgroups comp.lang.c++
Subject Re: std::ifstream multithread
Date 2011-05-27 15:04 +0200
Organization 1&1 Internet AG
Message-ID <iro7gi$irt$1@online.de> (permalink)
References <irnu08$b8f$1@online.de> <iro5ia$65h$1@dont-email.me>

Show all headers | View raw


On 2011-05-27 14:31:05 +0200, Victor Bazarov said:

> On 5/27/2011 6:22 AM, Philipp Kraus wrote:
>> I must read a lot of files like this
>> 
>> std::ifstream l_file;
>> 
>> l_file.open(p_str1.c_str(), std::ifstream::binary);
>> std::copy( std::istream_iterator<char>(l_file),
>> std::istream_iterator<char>(),
>> std::ostreambuf_iterator<char>(&l_deflate) );
>> l_file.close();
>> 
>> I deflate the file content with bzip. I would do this in a multithread
>> content, so my question is, can I do this without any problems during
>> reading?
>> In some cases two thread can use the same file (p_str1 is in two threads
>> equal). Can i read the same file out of two thread or is a mutex required?
> 
> You need to consult your compiler and/or standard library manual.

I use g++ and Visual Studio, du you know anything about it? In my 
option the OS should be manage the access to the files.

Thx

Phil

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

std::ifstream multithread Philipp Kraus <philipp.kraus@flashpixx.de> - 2011-05-27 12:22 +0200
  Re: std::ifstream multithread Victor Bazarov <v.bazarov@comcast.invalid> - 2011-05-27 08:31 -0400
    Re: std::ifstream multithread Philipp Kraus <philipp.kraus@flashpixx.de> - 2011-05-27 15:04 +0200
      Re: std::ifstream multithread Victor Bazarov <v.bazarov@comcast.invalid> - 2011-05-27 09:19 -0400
        Re: std::ifstream multithread Philipp Kraus <philipp.kraus@flashpixx.de> - 2011-05-27 16:51 +0200
  Re: std::ifstream multithread Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-05-27 15:17 +0000

csiph-web