File: lockable.cc

package info (click to toggle)
apt-cacher-ng 3.3.1-2~bpo10+1
  • links: PTS, VCS
  • area: main
  • in suites: buster-backports
  • size: 2,040 kB
  • sloc: cpp: 17,564; sh: 553; ansic: 401; perl: 377; makefile: 126
file content (25 lines) | stat: -rw-r--r-- 587 bytes parent folder | download | duplicates (8)
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

#include "debug.h"

#include <config.h>
#include "lockable.h"

#include <chrono>

namespace acng
{
bool base_with_condition::wait_until(lockuniq& uli, time_t nUTCsecs, long msec)
{
	auto tpUTC = std::chrono::system_clock::from_time_t(nUTCsecs);
	tpUTC += std::chrono::milliseconds(msec);
	auto r = m_obj_cond.wait_until(uli._guard, tpUTC);
	return std::cv_status::timeout == r;
}

bool base_with_condition::wait_for(lockuniq& uli, long secs, long msec)
{
	auto r = m_obj_cond.wait_for(uli._guard, std::chrono::milliseconds(msec + secs*1000));
	return std::cv_status::timeout == r;
}

}