X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fio%2Fbase.cpp;h=da2b5a98cb1c8db3f211b292137783b0c19d4e7d;hb=f64c9011fd50c4e7b3015ab934b09f95ffa8673b;hp=fe706fd5b3cf5cad6b7c5b52e5f229992d5ac933;hpb=df5ab3d867c51d72344e443e3adb05bfa29a2b53;p=libs%2Fcore.git diff --git a/source/io/base.cpp b/source/io/base.cpp index fe706fd..da2b5a9 100644 --- a/source/io/base.cpp +++ b/source/io/base.cpp @@ -8,12 +8,14 @@ namespace IO { Base::Base(): mode(M_READ), - eof_flag(false) + eof_flag(false), + mutex(0) { } Base::~Base() { signal_deleted.emit(); + delete mutex; } void Base::check_access(Mode m) const @@ -48,5 +50,33 @@ int Base::get() return static_cast(c); } +void Base::set_eof() +{ + if(!eof_flag) + { + eof_flag = true; + signal_end_of_file.emit(); + } +} + +const Handle &Base::get_handle(Mode) +{ + throw logic_error("Base::get_handle"); +} + + +Base::Synchronize::Synchronize(Base &i): + io(i) +{ + if(!io.mutex) + io.mutex = new Mutex; + io.mutex->lock(); +} + +Base::Synchronize::~Synchronize() +{ + io.mutex->unlock(); +} + } // namespace IO } // namespace Msp