forked from hep-cce2/root_serialization
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSerializerWrapper.h
More file actions
43 lines (37 loc) · 1.26 KB
/
SerializerWrapper.h
File metadata and controls
43 lines (37 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#if !defined(SerializerWrapper_h)
#define SerializerWrapper_h
#include <vector>
#include <chrono>
#include "TClass.h"
#include "tbb/task_group.h"
#include "Serializer.h"
#include "TaskHolder.h"
namespace cce::tf {
class SerializerWrapper {
public:
SerializerWrapper(std::string_view iName, TClass* tClass):
name_{iName}, class_(tClass), serializer_{},
accumulatedTime_{std::chrono::microseconds::zero()} {}
void doWorkAsync(tbb::task_group& iGroup, void** iAddress, TaskHolder iCallback) {
iGroup.run([this, iAddress, callback=std::move(iCallback)] () {
{
auto start = std::chrono::high_resolution_clock::now();
blob_ = serializer_.serialize(*iAddress, class_);
accumulatedTime_ += std::chrono::duration_cast<decltype(accumulatedTime_)>(std::chrono::high_resolution_clock::now() - start);
}
const_cast<TaskHolder&>(callback).doneWaiting();
});
}
std::vector<char> const& blob() const {return blob_;}
std::string_view name() const {return name_;}
char const* className() const { return class_->GetName(); }
std::chrono::microseconds accumulatedTime() const { return accumulatedTime_;}
private:
std::vector<char> blob_;
std::string_view name_;
TClass* class_;
Serializer serializer_;
std::chrono::microseconds accumulatedTime_;
};
}
#endif