55void rim::Transaction::setup_python() {
57 bp::class_<rim::Transaction, rim::TransactionPtr, boost::noncopyable>(
"Transaction", bp::no_init)
58 .def(
"lock", &rim::Transaction::lock)
59 .def(
"id", &rim::Transaction::id)
60 .def(
"address", &rim::Transaction::address)
61 .def(
"size", &rim::Transaction::size)
62 .def(
"type", &rim::Transaction::type)
63 .def(
"done", &rim::Transaction::done)
64 .def(
"error", &rim::Transaction::errorStr)
65 .def(
"expired", &rim::Transaction::expired)
66 .def(
"setData", &rim::Transaction::setData)
67 .def(
"getData", &rim::Transaction::getData);
142 subTran->parentTransaction_ = shared_from_this();
143 subTran->isSubTransaction_ =
true;
144 subTranMap_[subTran->id()] = subTran;
145 log_->debug(
"Created subTransaction id=%" PRIu32
", parent=%" PRIu32, subTran->id_, this->id_);
226std::string rim::Transaction::wait() {
227 struct timeval currTime;
229 std::unique_lock<std::mutex> lock(lock_);
233 gettimeofday(&currTime, NULL);
234 if (endTime_.tv_sec != 0 && endTime_.tv_usec != 0 && timercmp(&currTime, &(endTime_), >)) {
236 error_ =
"Timeout waiting for register transaction " + std::to_string(id_) +
" message response.";
238 log_->debug(
"Transaction timeout. type=%" PRIu32
" id=%" PRIu32
", address=0x%" PRIx64
", size=%" PRIu32,
244 cond_.wait_for(lock, std::chrono::microseconds(1000));
252 PyBuffer_Release(&(pyBuf_));
263 struct timeval currTime;
264 struct timeval nextTime;
266 gettimeofday(&currTime, NULL);
267 std::lock_guard<std::mutex> lock(lock_);
270 if (ref == NULL || timercmp(&startTime_, &(ref->startTime_), >=)) {
271 timeradd(&currTime, &timeout_, &endTime_);
273 if (warnTime_.tv_sec == 0 && warnTime_.tv_usec == 0) {
274 warnTime_ = endTime_;
275 }
else if (timercmp(&warnTime_, &currTime, >=)) {
276 log_->warning(
"Transaction timer refresh! Possible slow link! type=%" PRIu32
" id=%" PRIu32
277 ", address=0x%016" PRIx64
", size=%" PRIu32,
282 warnTime_ = endTime_;
302void rim::Transaction::setData(boost::python::object p, uint32_t offset) {
305 if (PyObject_GetBuffer(p.ptr(), &pyBuf, PyBUF_SIMPLE) < 0)
308 uint32_t count = pyBuf.len;
310 if ((offset + count) > size_) {
311 PyBuffer_Release(&pyBuf);
313 "Attempt to set %" PRIu32
" bytes at offset %" PRIu32
314 " to python buffer with size %" PRIu32,
320 std::memcpy(begin() + offset,
reinterpret_cast<uint8_t*
>(pyBuf.buf), count);
321 PyBuffer_Release(&pyBuf);
325void rim::Transaction::getData(boost::python::object p, uint32_t offset) {
328 if (PyObject_GetBuffer(p.ptr(), &pyBuf, PyBUF_CONTIG) < 0)
331 uint32_t count = pyBuf.len;
333 if ((offset + count) > size_) {
334 PyBuffer_Release(&pyBuf);
336 "Attempt to get %" PRIu32
" bytes from offset %" PRIu32
337 " to python buffer with size %" PRIu32,
343 std::memcpy(
reinterpret_cast<uint8_t*
>(pyBuf.buf), begin() + offset, count);
344 PyBuffer_Release(&pyBuf);