2828#include < queue>
2929#include < future>
3030#include < Modules/Basic/AsyncStreamingTestModule.h>
31+ #include < Modules/Basic/SimulationReaderBaseModule.h>
3132#include < Core/Datatypes/Legacy/Bundle/Bundle.h>
3233#include < Core/Datatypes/DenseMatrix.h>
3334#include < Core/Datatypes/DenseColumnMatrix.h>
@@ -48,7 +49,7 @@ namespace SCIRun::Modules::Basic
4849 using DataChunk = DenseMatrixHandle;
4950 // TODO: need thread-safe container to share
5051 using DataStream = std::queue<DataChunk>;
51-
52+
5253
5354 class StreamAppender
5455 {
@@ -92,22 +93,22 @@ namespace SCIRun::Modules::Basic
9293 {
9394 if (hasData ())
9495 {
95- // wait for result.
96+ // wait for result.
9697 while (stream ().empty ())
9798 {
9899 logInfo (" __MAIN__ Waiting for data" );
99100 std::this_thread::sleep_for (std::chrono::milliseconds (1000 ));
100101 }
101102
102- // once data is available, output to ports
103+ // once data is available, output to ports
103104 auto data = stream ().front ();
104105 {
105106 Guard g (dataMutex.get ());
106107 stream ().pop ();
107108 }
108109
109110 logInfo (" __MAIN__ Received data: [{}] outputting matrix." , (*data)(0 , 0 ));
110- module_->outputAsyncData (module_->bundleOutputs ({ " Slice" }, { data }));
111+ module_->sendOutput (module_->OutputSlice , bundleOutputs ({ " Slice" }, { data }));
111112
112113 logInfo (" __MAIN__ Enqueue execute again" );
113114 module_->enqueueExecuteAgain (false );
@@ -149,23 +150,6 @@ void AsyncStreamingTest::execute()
149150 impl_ = std::make_unique<StreamAppender>(this , castMatrix::toDense (input));
150151 impl_->beginPushDataAsync ();
151152 }
152-
153- impl_->waitAndOutputEach ();
154- }
155-
156- void AsyncStreamingTest::outputAsyncData (BundleHandle data)
157- {
158- sendOutput (OutputSlice, data);
159- }
160153
161- Core::Datatypes::BundleHandle AsyncStreamingTest::bundleOutputs (std::initializer_list<std::string> names, std::initializer_list<DatatypeHandle> dataList)
162- {
163- auto bundle = makeShared<Bundle>();
164- auto nIter = names.begin ();
165- auto dIter = dataList.begin ();
166- for (; nIter != names.end (); ++nIter, ++dIter)
167- {
168- bundle->set (*nIter, *dIter);
169- }
170- return bundle;
154+ impl_->waitAndOutputEach ();
171155}
0 commit comments