| | |
| | | int LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::push_timeout(const ELEM_T &a_data, const struct timespec * ts) |
| | | { |
| | | |
| | | |
| | | int rv; |
| | | struct timespec timeout = PXSemUtil::calc_sem_timeout(ts); |
| | | // LoggerFactory::getLogger()->debug("==================LockFreeQueue push_timeout before tv_sec=%d, tv_nsec=%ld", |
| | | // timeout.tv_sec, timeout.tv_nsec); |
| | | |
| | | while (sem_timedwait(&slots, &timeout) == -1) { |
| | | while ( sem_timedwait(&slots, &timeout) == -1) { |
| | | // LoggerFactory::getLogger()->debug("==================LockFreeQueue push_timeout before tv_sec=%d, tv_nsec=%ld, ETIMEDOUT=%d, errno=%d\n", |
| | | // timeout.tv_sec, timeout.tv_nsec, ETIMEDOUT, errno); |
| | | |
| | |
| | | template <typename T, typename AT> class Q_TYPE> |
| | | int LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::pop_timeout(ELEM_T &a_data, struct timespec * ts) |
| | | { |
| | | // LoggerFactory::getLogger()->debug("==================LockFreeQueue pop_timeout before\n"); |
| | | // LoggerFactory::getLogger()->debug("=================ts sec = %d, nsec = %ld \n", ts->tv_sec, ts->tv_nsec ); |
| | | |
| | | // struct timespec timeout_tmp = {1, 0}; |
| | | struct timespec timeout = PXSemUtil::calc_sem_timeout(ts); |
| | | // LoggerFactory::getLogger()->debug("================== timeout before sec = %d, nsec = %ld \n", timeout.tv_sec, timeout.tv_nsec ); |
| | | |
| | | while (sem_timedwait(&items, &timeout) == -1) { |
| | | if (errno == ETIMEDOUT) |
| | |
| | | else if(errno == EINTR) |
| | | continue; |
| | | else { |
| | | LoggerFactory::getLogger()->error(errno, "LockFreeQueue pop_timeout"); |
| | | return -1; |
| | | // LoggerFactory::getLogger()->error(errno, "LockFreeQueue pop_timeout %d", errno); |
| | | return errno; |
| | | } |
| | | } |
| | | |