mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 09:31:45 +00:00
Add example with ref-counted copy from unmanaged region
This commit is contained in:
@@ -22,7 +22,8 @@ struct Sink : Device
|
||||
{
|
||||
// Get the fMaxIterations value from the command line options (via fConfig)
|
||||
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
||||
GetChannel("data", 0).Transport()->SubscribeToRegionEvents([](RegionInfo info) {
|
||||
fChanName = fConfig->GetProperty<std::string>("chan-name");
|
||||
GetChannel(fChanName, 0).Transport()->SubscribeToRegionEvents([](RegionInfo info) {
|
||||
LOG(info) << "Region event: " << info.event << ": "
|
||||
<< (info.managed ? "managed" : "unmanaged") << ", id: " << info.id
|
||||
<< ", ptr: " << info.ptr << ", size: " << info.size
|
||||
@@ -32,11 +33,11 @@ struct Sink : Device
|
||||
|
||||
void Run() override
|
||||
{
|
||||
Channel& dataInChannel = GetChannel("data", 0);
|
||||
Channel& dataIn = GetChannel(fChanName, 0);
|
||||
|
||||
while (!NewStatePending()) {
|
||||
auto msg(dataInChannel.Transport()->CreateMessage());
|
||||
dataInChannel.Receive(msg);
|
||||
auto msg(dataIn.Transport()->CreateMessage());
|
||||
dataIn.Receive(msg);
|
||||
|
||||
// void* ptr = msg->GetData();
|
||||
// char* cptr = static_cast<char*>(ptr);
|
||||
@@ -51,22 +52,22 @@ struct Sink : Device
|
||||
|
||||
void ResetTask() override
|
||||
{
|
||||
GetChannel("data", 0).Transport()->UnsubscribeFromRegionEvents();
|
||||
GetChannel(fChanName, 0).Transport()->UnsubscribeFromRegionEvents();
|
||||
}
|
||||
|
||||
private:
|
||||
uint64_t fMaxIterations = 0;
|
||||
uint64_t fNumIterations = 0;
|
||||
std::string fChanName;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void addCustomOptions(bpo::options_description& options)
|
||||
{
|
||||
options.add_options()(
|
||||
"max-iterations",
|
||||
bpo::value<uint64_t>()->default_value(0),
|
||||
"Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)");
|
||||
options.add_options()
|
||||
("chan-name", bpo::value<std::string>()->default_value("data"), "name of the input channel")
|
||||
("max-iterations", bpo::value<uint64_t>()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)");
|
||||
}
|
||||
|
||||
unique_ptr<Device> getDevice(ProgOptions& /*config*/) { return make_unique<Sink>(); }
|
||||
|
Reference in New Issue
Block a user