MCPcopy Create free account
hub / github.com/Tencent/TAD_Sim / write

Method write

simcore/framework/examples/camera/memory_io.cpp:59–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59bool SharedMemoryWriter::write(const std::vector<uint8_t>& buffer, const int64_t timestamp) {
60 using namespace boost::interprocess;
61 using namespace boost::posix_time;
62
63 try {
64 if (!shared_segment_->ptr_)
65 // while (!shared_segment_->mtx_->timed_lock(microsec_clock::universal_time() +
66 // microseconds(max_lock_wait_microsecond_)))
67 {
68 // printf("SharedMemeory icannot get lock,remove lock\n");
69 if (!reset()) {
70 printf("SharedMemory write init failed\n");
71 return false;
72 }
73 }
74
75 if (shared_segment_->ptr_) {
76 int sz = buffer.size();
77 int ptr_sz = sizeof(int) + sizeof(int64_t) + sizeof(int) + sz + 1024;
78 if (shared_segment_->ptr_->size() < ptr_sz) {
79 shared_segment_->ptr_->resize(ptr_sz);
80 }
81 char* buf = shared_segment_->ptr_->data();
82 memcpy(buf, &kMagicNumber_, sizeof(int));
83 buf += sizeof(int);
84 memcpy(buf, &timestamp, sizeof(int64_t));
85 buf += sizeof(int64_t);
86 memcpy(buf, &sz, sizeof(int));
87 buf += sizeof(int);
88 memcpy(buf, buffer.data(), sz);
89 // shared_segment_->mtx_->unlock();
90 }
91 } catch (...) {
92 printf("SharedMemory write failed\n");
93 // shared_segment_->mtx_->unlock();
94 return false;
95 }
96
97 return true;
98}
99
100bool SharedMemoryWriter::remove() {
101 // if (shared_segment_)

Callers 15

mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
saveGridsMethod · 0.45
saveSBordersMethod · 0.45
dumpToFileMethod · 0.45
upgrade_sensor.pyFile · 0.45
launch_test_loadFunction · 0.45
LoggingPerfStatsMethod · 0.45
prepare_run_envFunction · 0.45
saveJpgFunction · 0.45

Calls 5

printfFunction · 0.85
resetFunction · 0.50
sizeMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45

Tested by 2

mainFunction · 0.36
launch_test_loadFunction · 0.36