diff --git a/components/streams/src/filestream.cpp b/components/streams/src/filestream.cpp index 9121abbdd435a9005fff30197c7acbbdc53a8218..102d05890c0e30866109d25873fe361f51447dd1 100644 --- a/components/streams/src/filestream.cpp +++ b/components/streams/src/filestream.cpp @@ -399,6 +399,10 @@ bool File::end() { UNIQUE_LOCK(mutex_, lk); + while (jobs_ > 0) { + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + } + if (mode_ == Mode::Read) { if (istream_) { istream_->close(); diff --git a/components/streams/test/filestream_unit.cpp b/components/streams/test/filestream_unit.cpp index ec05be42f71814e7c1692e9c2d1d2826d619ea46..25c33b5800c5be2e3752fa48f1120675d1c88b88 100644 --- a/components/streams/test/filestream_unit.cpp +++ b/components/streams/test/filestream_unit.cpp @@ -43,7 +43,8 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") { }); REQUIRE( reader->begin(false) ); - //reader->tick(); + reader->tick(100); + reader->end(); //REQUIRE( tspkt.timestamp == 0 ); REQUIRE( tspkt.streamID == (uint8_t)2 ); @@ -73,7 +74,8 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") { }); REQUIRE( reader->begin(false) ); - //reader->tick(); + reader->tick(100); + reader->end(); REQUIRE( count == 3 ); REQUIRE( tspkt.timestamp > 0 ); @@ -105,21 +107,22 @@ TEST_CASE("ftl::stream::File write and read", "[stream]") { }); REQUIRE( reader->begin(false) ); - //reader->tick(); + reader->tick(100); + std::this_thread::sleep_for(std::chrono::milliseconds(10)); REQUIRE( count == 1 ); //REQUIRE( tspkt.timestamp == 0 ); //auto itime = tspkt.timestamp; count = 0; - reader->tick(0); + reader->tick(101); std::this_thread::sleep_for(std::chrono::milliseconds(10)); REQUIRE( count == 1 ); //REQUIRE( tspkt.timestamp == itime+ftl::timer::getInterval() ); count = 0; - reader->tick(0); + reader->tick(102); std::this_thread::sleep_for(std::chrono::milliseconds(10)); REQUIRE( count == 1 );