本文整理汇总了C++中period函数的典型用法代码示例。如果您正苦于以下问题:C++ period函数的具体用法?C++ period怎么用?C++ period使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了period函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: timer_alloc
void clock_device::update_timer()
{
if (!m_signal_handler.isnull() && m_clock > 0)
{
if (m_timer == nullptr)
{
m_timer = timer_alloc(0);
m_timer->adjust(period());
}
else
{
attotime next = period() - m_timer->elapsed();
if (next < attotime::zero)
{
next = attotime::zero;
}
m_timer->adjust(next);
}
}
else if (m_timer != nullptr)
{
m_timer->adjust(attotime::never);
}
}
示例2: main
int main()
{
int i,c=0,cPrev=-1;
for(i=3;i<=1000;i++)
{
c=period(i);
if(c>cPrev)
{
cPrev=c;
//printf("ok 1");
printf("%d = %d\n",i,period(i));//printf("Period : %d = %d \n",i,period(i));
}
}
}
示例3: period
// Note: not guaranteed to print entire state
void PulseWave::printState(void) {
const char *enabledStr = enabled ? "enabled" : "disabled";
float frequency = 1.0 / period();
printf("Pulse wave channel %d: %s, duty %f, divider %d (%f Hz)\n",
// dummy channel number below
-1, enabledStr, duty, divider, frequency);
}
示例4: m_signal_handler
void clock_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
m_signal = !m_signal;
m_signal_handler(m_signal);
m_timer->adjust(period());
}
示例5: sigaddset
void
GroupNodeImpl::update_groups()
{
#ifndef _WIN32
sigset_t signal_set;
sigaddset(&signal_set, SIGINT);
sigaddset(&signal_set, SIGTERM);
sigaddset(&signal_set, SIGHUP);
sigaddset(&signal_set, SIGPIPE);
pthread_sigmask(SIG_BLOCK, &signal_set, NULL);
#endif
// called by a thread in an infinite loop at a fixed rate (i.e. 1s)
while (ok()) {
auto start = std::chrono::high_resolution_clock::now();
zlist_t* all_groups = zyre_peer_groups(node_);
void* item = zlist_first(all_groups);
while (item != NULL) {
char* grp = static_cast<char*>(item);
// zyre only joins the group if we are not ALREADY in the group
// so it does a hash lookup - we would be duplicating work
zyre_join(node_, grp);
item = zlist_next(all_groups);
}
std::chrono::duration<double,std::milli> period(1000);
std::this_thread::sleep_until(start + period);
}
}
示例6: assert
OsStatus MpodBufferRecorder::enableDevice(unsigned samplesPerFrame,
unsigned samplesPerSec,
MpFrameTime currentFrameTime,
OsCallback &frameTicker)
{
assert(!isEnabled());
assert(mpBuffer == NULL);
mSamplesPerFrame = samplesPerFrame;
mSamplesPerSec = samplesPerSec;
mBufferLength = mBufferLengthMS * mSamplesPerSec / 1000;
mpBuffer = new MpAudioSample[mBufferLength];
mBufferEnd = 0;
mIsEnabled = TRUE;
if (mpTickerTimer != NULL)
{
mpTickerTimer->stop(TRUE);
delete mpTickerTimer;
mpTickerTimer = NULL;
}
mpTickerNotification = &frameTicker;
// Start firing events
mpTickerTimer = new OsTimer((OsNotification&)*mpTickerNotification);
OsTime period(samplesPerFrame*1000/samplesPerSec);
mpTickerTimer->periodicEvery(period, period);
return OS_SUCCESS;
}
示例7: period
void z80ctc_device::ctc_channel::trigger(uint8_t data)
{
// normalize data
data = data ? 1 : 0;
// see if the trigger value has changed
if (data != m_extclk)
{
m_extclk = data;
// see if this is the active edge of the trigger
if (((m_mode & EDGE) == EDGE_RISING && data) || ((m_mode & EDGE) == EDGE_FALLING && !data))
{
// if we're waiting for a trigger, start the timer
if ((m_mode & WAITING_FOR_TRIG) && (m_mode & MODE) == MODE_TIMER)
{
attotime curperiod = period();
VPRINTF_CHANNEL(("CTC period %s\n", curperiod.as_string()));
m_timer->adjust(curperiod, m_index, curperiod);
}
// we're no longer waiting
m_mode &= ~WAITING_FOR_TRIG;
// if we're clocking externally, decrement the count
if ((m_mode & MODE) == MODE_COUNTER)
{
// if we hit zero, do the same thing as for a timer interrupt
if (--m_down == 0)
timer_callback(nullptr,0);
}
}
}
}
示例8: spin
bool spin()
{
ros::Duration period(4,0) ; // Repeat Every 4 seconds
ros::Time next_time = ros::Time::now() ;
while ( ok() )
{
usleep(100) ;
if (ros::Time::now() >= next_time)
{
next_time.from_double(next_time.to_double() + period.to_double()) ;
BuildCloud::request req ;
BuildCloud::response resp ;
req.begin.from_double(next_time.to_double() - period.to_double() ) ;
req.end = next_time ;
req.target_frame_id = "base" ;
printf("Making Service Call...\n") ;
ros::service::call("build_cloud", req, resp) ;
printf("Done with service call\n") ;
publish("full_cloud", resp.cloud) ;
printf("Published Cloud size=%u\n", resp.cloud.get_pts_size()) ;
}
}
return true ;
}
示例9: install_readwrite_handler
void hp98035_io_card::device_reset()
{
hp9845_io_card_device::device_reset();
install_readwrite_handler(read16_delegate(FUNC(hp98035_io_card::reg_r) , this) , write16_delegate(FUNC(hp98035_io_card::reg_w) , this));
m_idr_full = false;
m_idr = 0;
m_odr = 0;
m_ibuffer_ptr = 0;
m_obuffer_len = 0;
m_obuffer_ptr = 0;
sts_w(true);
set_flg(true);
// Set real time from the real world
system_time systime;
machine().base_datetime(systime);
m_msec = 0;
m_sec = systime.local_time.second;
m_min = systime.local_time.minute;
m_hrs = systime.local_time.hour;
m_dom = systime.local_time.mday;
m_mon = systime.local_time.month + 1;
attotime period(attotime::from_msec(1));
m_msec_timer->adjust(period , 0 , period);
half_init();
}
示例10: PWMObject
FastPWM::FastPWM(PinName pin) : PWMObject(pin){
//Set clock source
LPC_SC->PCLKSEL0|=1<<12;
_duty=0;
_period=0.02;
if (pin==p26||pin==LED1) {
PWMUnit=1;
MR=&LPC_PWM1->MR1;
}
else if (pin==p25||pin==LED2){
PWMUnit=2;
MR=&LPC_PWM1->MR2;
}
else if (pin==p24||pin==LED3){
PWMUnit=3;
MR=&LPC_PWM1->MR3;
}
else if (pin==p23||pin==LED4){
PWMUnit=4;
MR=&LPC_PWM1->MR4;
}
else if (pin==p22){
PWMUnit=5;
MR=&LPC_PWM1->MR5;
}
else if (pin==p21){
PWMUnit=6;
MR=&LPC_PWM1->MR6;
}
else
error("No hardware PWM pin\n\r");
period(_period);
}
示例11: TEST_F
TEST_F(PeriodicActionPoolTest, cancellation)
{
PeriodicActionPool::Ptr pool(PeriodicActionPool::create("TestPool",
nthreads_));
boost::promise<bool> promise;
boost::unique_future<bool> future(promise.get_future());
bool running = false;
auto fun([&]() -> PeriodicActionContinue
{
if (not running)
{
promise.set_value(true);
running = true;
}
return PeriodicActionContinue::T;
});
std::atomic<uint64_t> period(3600);
std::unique_ptr<PeriodicActionPool::Task> t(pool->create_task("LongPeriod",
std::move(fun),
period,
true));
EXPECT_TRUE(future.get());
}
示例12: NS_ENSURE_TRUE
nsresult
nsDASHWebMODParser::SetPeriods(MPD* aMpd)
{
NS_ENSURE_TRUE(mRoot, NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsIDOMElement> child, nextChild;
nsresult rv = mRoot->GetFirstElementChild(getter_AddRefs(child));
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
#ifdef PR_LOGGING
int i = 0;
#endif
while (child) {
nsAutoString tagName;
rv = child->GetTagName(tagName);
NS_ENSURE_SUCCESS(rv, rv);
if (tagName.EqualsLiteral("Period")) {
nsAutoPtr<Period> period(new Period());
// Get start time and duration
nsAutoString value;
rv = GetAttribute(child, NS_LITERAL_STRING("start"), value);
NS_ENSURE_SUCCESS(rv, rv);
if (!value.IsEmpty()) {
double startTime = -1;
rv = GetTime(value, startTime);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(0 <= startTime, NS_ERROR_ILLEGAL_VALUE);
period->SetStart(startTime);
}
rv = GetAttribute(child, NS_LITERAL_STRING("duration"), value);
NS_ENSURE_SUCCESS(rv, rv);
if (!value.IsEmpty()) {
double duration = -1;
rv = GetTime(value, duration);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(0 <= duration, NS_ERROR_ILLEGAL_VALUE);
period->SetDuration(duration);
}
bool bIgnoreThisPeriod;
rv = SetAdaptationSets(child, period, bIgnoreThisPeriod);
NS_ENSURE_SUCCESS(rv, rv);
// |Period| should be ignored if its child elems are invalid
if (bIgnoreThisPeriod) {
LOG("Ignoring period");
} else {
aMpd->AddPeriod(period.forget());
LOG("Period #%d: added to MPD", i++);
}
}
rv = child->GetNextElementSibling(getter_AddRefs(nextChild));
NS_ENSURE_SUCCESS(rv, rv);
child = nextChild;
}
return NS_OK;
}
示例13: periodChanged
void EasingGraph::setPeriod(qreal newPeriod)
{
if ((period() != newPeriod) && (easingShape()==QLatin1String("Elastic"))) {
m_curveFunction.setPeriod(newPeriod);
emit periodChanged();
update();
}
}
示例14: idle_callback
void idle_callback(std::size_t /*num_thread*/)
{
#if defined(HPX_HAVE_THREAD_MANAGER_IDLE_BACKOFF)
// Put this thread to sleep for some time, additionally it gets
// woken up on new work.
#if BOOST_VERSION < 105000
boost::posix_time::millisec period(++wait_count_);
boost::unique_lock<boost::mutex> l(mtx_);
cond_.timed_wait(l, period);
#else
boost::chrono::milliseconds period(++wait_count_);
boost::unique_lock<boost::mutex> l(mtx_);
cond_.wait_for(l, period);
#endif
#endif
}
示例15: bind
static inline void bind(const std::shared_ptr<threading::Reaction>& reaction) {
// If this is the first time we have used this watchdog service it
if (!operation::CacheGet<message::ServiceWatchdog<WatchdogGroup>>::template get<DSL>(*reaction)) {
reaction->reactor.emit(std::make_unique<message::ServiceWatchdog<WatchdogGroup>>());
}
reaction->unbinders.push_back([](const threading::Reaction& r) {
r.reactor.emit<emit::Direct>(std::make_unique<operation::Unbind<operation::ChronoTask>>(r.id));
});
// Send our configuration out
reaction->reactor.emit<emit::Direct>(std::make_unique<operation::ChronoTask>(
[reaction](NUClear::clock::time_point& time) {
// Get the latest time the watchdog was serviced
auto service_time =
operation::CacheGet<message::ServiceWatchdog<WatchdogGroup>>::template get<DSL>(*reaction)
->time;
// Check if our watchdog has timed out
if (NUClear::clock::now() > (service_time + period(ticks))) {
try {
// Submit the reaction to the thread pool
auto task = reaction->get_task();
if (task) { reaction->reactor.powerplant.submit(std::move(task)); }
}
catch (...) {
}
// Now automatically service the watchdog
time = NUClear::clock::now() + period(ticks);
}
// Change our wait time to our new watchdog time
else {
time = service_time + period(ticks);
}
// We renew!
return true;
},
NUClear::clock::now() + period(ticks),
reaction->id));
}