当前位置: 首页>>代码示例>>C++>>正文


C++ Timeout::expired方法代码示例

本文整理汇总了C++中Timeout::expired方法的典型用法代码示例。如果您正苦于以下问题:C++ Timeout::expired方法的具体用法?C++ Timeout::expired怎么用?C++ Timeout::expired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timeout的用法示例。


在下文中一共展示了Timeout::expired方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setup

/**
 * Application setup
 */
void setup()
{
    bcu.begin(4, 0x7054, 2); // We are a "Jung 2118" device, version 0.2

    pinMode(PIO_LED, OUTPUT);
    digitalWrite(PIO_LED, 1);

    // Configure the input pins and initialize the debouncers with the current
    // value of the pin.
    for (int channel = 0; channel < NUM_CHANNELS; ++channel)
    {
        pinMode(inputPins[channel], INPUT | HYSTERESIS | PULL_UP);
        inputDebouncer[channel].init(digitalRead(inputPins[channel]));
    }

    // Handle configured power-up delay
    unsigned int startupTimeout = calculateTime
            ( userEeprom[EE_BUS_RETURN_DELAY_BASE] >> 4
            , userEeprom[EE_BUS_RETURN_DELAY_FACT] &  0x7F
            );
    Timeout delay;
    int debounceTime = userEeprom[EE_INPUT_DEBOUNCE_TIME] >> 1;
    delay.start(startupTimeout);
    while (delay.started() && !delay.expired())
    {   // while we wait for the power on delay to expire we debounce the input channels
        for (int channel = 0; channel < NUM_CHANNELS; ++channel)
        {
            inputDebouncer[channel].debounce(digitalRead(inputPins[channel]), debounceTime);
        }
        waitForInterrupt();
    }

    initApplication();
}
开发者ID:glueckm,项目名称:software-arm-incubation,代码行数:37,代码来源:app_main.cpp

示例2: checkPeriodicFuntions

void checkPeriodicFuntions(void)
{
	if(msTimeout.started() && msTimeout.expired()) {
		msTimeout.start(1);
		for (unsigned int i = 0; i < NO_OF_CHANNELS; i++)
		{
//			setChannelPWMRatio(i, pwm&0xffff);
//			pwm+=1;
			Channel * chn = channels[i];
			if (chn)
				chn->periodic();
		}
		memMapper.doFlash();
	}
	if(inBetriebTimeout.started() && inBetriebTimeout.expired()) {
		inBetriebTimeout.start(inBetriebZeit*1000);
		objectWrite(COMObj_In_Operation, inBetriebValue_0);
	}
	if(timeoutTest.started() && timeoutTest.expired()) {
		timeoutTest.start(1000);
//		objectWrite(209, inBetriebValue_0);
	}
}
开发者ID:baycom,项目名称:software-arm-incubation,代码行数:23,代码来源:app-out8-dimmer.cpp

示例3: initApplication

void initApplication(void)
{
    unsigned int address = currentVersion->baseAddress;
    setupPWM();

    for (unsigned int i = 0; i < NO_OF_CHANNELS; i++)
    {
        digitalWrite(outputPins[i], 0);
        pinMode(outputPins[i], OUTPUT);
        channels[i] = new Channel(i, address+16+i*256);
    }

    unsigned int initZeit = memMapper.getUInt8(P_InitZeit + address);
    Timeout startupDelay;
    if (initZeit)
    {
        startupDelay.start(initZeit);
        while (!startupDelay.expired())
        {
            waitForInterrupt();
        }
    }

/*  no yet used
    unsigned int telegrUnbegr = memMapper.getUInt8(PD_TelegrUnbegr + address);
    unsigned int telegrUebZeit = memMapper.getUInt16(P_TelegrUebZeit + address);
*/

    inBetrieb = memMapper.getUInt8(P_InBetrieb + address);
    inBetriebValue_0 = memMapper.getUInt8(P_InBetriebValue_0 + address);
    inBetriebZeit = memMapper.getUInt16(P_InBetriebZeit + address);

    if(inBetrieb != 255) {
    	inBetriebTimeout.start(1);
    }

    unsigned int einerFuerAlle = memMapper.getUInt8(t_EinerFuerAlle + address);

    msTimeout.start(1);
    timeoutTest.start(1);
}
开发者ID:baycom,项目名称:software-arm-incubation,代码行数:41,代码来源:app-out8-dimmer.cpp

示例4: initialize

  virtual void initialize()
  {
    // We retry zookeeper_init until the timeout elapses because we've
    // seen cases where temporary DNS outages cause the slave to abort
    // here. See MESOS-1326 for more information.
    // ZooKeeper masks EAI_AGAIN as EINVAL and a name resolution timeout
    // may be upwards of 30 seconds. As such, a 10 second timeout is not
    // enough. Hard code this to 10 minutes to be sure we're trying again
    // in the face of temporary name resolution failures. See MESOS-1523
    // for more information.
    const Timeout timeout_ = Timeout::in(Minutes(10));

    while (!timeout_.expired()) {
      zh = zookeeper_init(
          servers.c_str(),
          event,
          static_cast<int>(timeout.ms()),
          NULL,
          &callback,
          0);

      // Unfortunately, EINVAL is highly overloaded in zookeeper_init
      // and can correspond to:
      //   (1) Empty / invalid 'host' string format.
      //   (2) Any getaddrinfo error other than EAI_NONAME,
      //       EAI_NODATA, and EAI_MEMORY are mapped to EINVAL.
      // Either way, retrying is not problematic.
      if (zh == NULL && errno == EINVAL) {
        ErrnoError error("zookeeper_init failed");
        LOG(WARNING) << error.message << " ; retrying in 1 second";
        os::sleep(Seconds(1));
        continue;
      }

      break;
    }

    if (zh == NULL) {
      PLOG(FATAL) << "Failed to create ZooKeeper, zookeeper_init";
    }
  }
开发者ID:GregBowyer,项目名称:mesos,代码行数:41,代码来源:zookeeper.cpp

示例5: initialize

  virtual void initialize()
  {
    // There are two different timeouts here:
    //
    // (1) `sessionTimeout` is the client's proposed value for the
    // ZooKeeper session timeout.
    //
    // (2) `initLoopTimeout` is how long we are prepared to wait,
    // calling `zookeeper_init` in a loop, until a call succeeds.
    //
    // `sessionTimeout` is used to determine the liveness of our
    // ZooKeeper session. `initLoopTimeout` determines how long to
    // retry erroneous calls to `zookeeper_init`, because there are
    // cases when temporary DNS outages cause `zookeeper_init` to
    // return failure. ZooKeeper masks EAI_AGAIN as EINVAL and a name
    // resolution timeout may be upwards of 30 seconds. As such, a 10
    // second timeout (the default `sessionTimeout`) is not enough. We
    // hardcode `initLoopTimeout` to 10 minutes ensure we're trying
    // again in the face of temporary name resolution failures. See
    // MESOS-1523 for more information.
    //
    // Note that there are cases where `zookeeper_init` returns
    // success but we don't see a subsequent ZooKeeper event
    // indicating that our connection has been established. A common
    // cause for this situation is that the ZK hostname list resolves
    // to unreachable IP addresses. ZooKeeper will continue looping,
    // trying to connect to the list of IPs but never attempting to
    // re-resolve the input hostnames. Since DNS may have changed, we
    // close the ZK handle and create a new handle to ensure that ZK
    // will try to re-resolve the configured list of hostnames.
    // However, since we can't easily check if the `connected` ZK
    // event has been fired for this session yet, we implement this
    // timeout in `GroupProcess`. See MESOS-4546 for more information.
    const Timeout initLoopTimeout = Timeout::in(Minutes(10));

    while (!initLoopTimeout.expired()) {
      zh = zookeeper_init(
          servers.c_str(),
          event,
          static_cast<int>(sessionTimeout.ms()),
          nullptr,
          &callback,
          0);

      // Unfortunately, EINVAL is highly overloaded in zookeeper_init
      // and can correspond to:
      //   (1) Empty / invalid 'host' string format.
      //   (2) Any getaddrinfo error other than EAI_NONAME,
      //       EAI_NODATA, and EAI_MEMORY are mapped to EINVAL.
      // Either way, retrying is not problematic.
      if (zh == nullptr && errno == EINVAL) {
        ErrnoError error("zookeeper_init failed");
        LOG(WARNING) << error.message << " ; retrying in 1 second";
        os::sleep(Seconds(1));
        continue;
      }

      break;
    }

    if (zh == nullptr) {
      PLOG(FATAL) << "Failed to create ZooKeeper, zookeeper_init";
    }
  }
开发者ID:EronWright,项目名称:mesos,代码行数:64,代码来源:zookeeper.cpp

示例6: wait

PollSelect::WaitStatus PollSelect::wait(const Timeout& tm, Result& result) {

	do {
		Timeout finTm = tm;
		if (!timeoutHeap.empty()) {
			Timeout p = timeoutHeap.top().owner->timeout;
			SysTime now = SysTime::now();
			while (p.expired(now)) {
				FdInfo *owner = timeoutHeap.top().owner;
				removeOldTm(owner);
				if (owner->waitFor != 0) {
					result.fd = getFd(owner);
					result.flags = 0;
					result.userData = owner->userData;
					owner->waitFor = 0;
					removeFromPool(owner->poolpos);
					return waitEvent;
				}
				if (timeoutHeap.empty()) break;
				p = timeoutHeap.top().owner->timeout;
			}
			if (p < finTm) finTm = p;
		}

		natural timeout_msecs = finTm.getRemain().msecs();
		int res = poll(curpool.data(),curpool.length(),timeout_msecs);
		if (res == -1) {
			if (errno != EINTR) throw ErrNoException(THISLOCATION,errno);
		}
		else if (res == 0) {
			if (tm.expired()) {
				return waitTimeout;
			} else {
				FdInfo *finfo = timeoutHeap.top().owner;
				removeOldTm(finfo);
				result.fd = getFd(finfo);
				result.flags = 0;
				result.userData = finfo->userData;
				finfo->waitFor = 0;
				removeFromPool(finfo->poolpos);
				return waitEvent;
			}
		} else {
			for (natural i = 0; i < curpool.length(); i++) {
				if (curpool[i].revents) {
					int fd = curpool[i].fd;
					int revents = curpool[i].revents;

					if (fd == wakeOut) {
						byte b;
						int r = read(wakeOut,&b,1);
						if (r == -1)
							throw ErrNoException(THISLOCATION, errno);
						result.fd = 0;
						result.userData = 0;
						result.reason = reason;
						return waitWakeUp;
					} else  {
						FdInfo *finfo = socketMap.data()+fd;
						removeOldTm(finfo);
						removeFromPool(i);
						if (finfo->waitFor) {
							result.fd = fd;
							result.flags = (((revents & POLL_IN)!=0)?INetworkResource::waitForInput:0) |
									(((revents & POLL_OUT)!=0)?INetworkResource::waitForOutput:0) |
									(((revents & (POLL_PRI|POLL_ERR))!=0)?INetworkResource::waitForException:0);
							result.userData = finfo->userData;
							finfo->waitFor = 0;
							return waitEvent;
						}
					}
				}
			}
		}
	} while (true);



}
开发者ID:ondra-novak,项目名称:lightspeed,代码行数:79,代码来源:pollSelect.cpp

示例7: _check_expired_yes

static void _check_expired_yes(void * refState, unsigned int param)
{
	REQUIRE(to.expired() == true);
	REQUIRE(to.started() == false);
	REQUIRE(to.stopped() == true);
}
开发者ID:FlorianVoelzke,项目名称:software-arm-lib,代码行数:6,代码来源:timeout_test.cpp

示例8: fetcher

// This is the same logic as ResourceStatistics, except the task should
// be allowed to exceed the disk quota, and usage statistics should report
// that the quota was exceeded.
TEST_F(ROOT_XFS_QuotaTest, ResourceStatisticsNoEnforce)
{
  Try<Owned<cluster::Master>> master = StartMaster();
  ASSERT_SOME(master);

  slave::Flags flags = CreateSlaveFlags();
  flags.enforce_container_disk_quota = false;

  Fetcher fetcher(flags);
  Owned<MasterDetector> detector = master.get()->createDetector();

  Try<MesosContainerizer*> _containerizer =
    MesosContainerizer::create(flags, true, &fetcher);

  ASSERT_SOME(_containerizer);
  Owned<MesosContainerizer> containerizer(_containerizer.get());

  Try<Owned<cluster::Slave>> slave =
    StartSlave(detector.get(), containerizer.get(), flags);
  ASSERT_SOME(slave);

  MockScheduler sched;

  MesosSchedulerDriver driver(
      &sched, DEFAULT_FRAMEWORK_INFO, master.get()->pid, DEFAULT_CREDENTIAL);
  EXPECT_CALL(sched, registered(_, _, _));

  Future<vector<Offer>> offers;
  EXPECT_CALL(sched, resourceOffers(_, _))
    .WillOnce(FutureArg<1>(&offers))
    .WillRepeatedly(Return()); // Ignore subsequent offers.

  driver.start();

  AWAIT_READY(offers);
  ASSERT_FALSE(offers->empty());

  Offer offer = offers.get()[0];

  // Create a task that uses 4MB of 3MB disk and fails if it can't
  // write the full amount.
  TaskInfo task = createTask(
      offer.slave_id(),
      Resources::parse("cpus:1;mem:128;disk:3").get(),
      "dd if=/dev/zero of=file bs=1048576 count=4 && sleep 1000");

  Future<TaskStatus> startingStatus;
  Future<TaskStatus> runningStatus;
  EXPECT_CALL(sched, statusUpdate(&driver, _))
    .WillOnce(FutureArg<1>(&startingStatus))
    .WillOnce(FutureArg<1>(&runningStatus))
    .WillRepeatedly(Return()); // Ignore subsequent updates.

  driver.launchTasks(offers.get()[0].id(), {task});

  AWAIT_READY(startingStatus);
  EXPECT_EQ(task.task_id(), startingStatus->task_id());
  EXPECT_EQ(TASK_STARTING, startingStatus->state());

  AWAIT_READY(runningStatus);
  EXPECT_EQ(task.task_id(), runningStatus->task_id());
  EXPECT_EQ(TASK_RUNNING, runningStatus->state());

  Future<hashset<ContainerID>> containers = containerizer.get()->containers();
  AWAIT_READY(containers);
  ASSERT_EQ(1u, containers->size());

  ContainerID containerId = *(containers->begin());
  Duration diskTimeout = Seconds(5);
  Timeout timeout = Timeout::in(diskTimeout);

  while (true) {
    Future<ResourceStatistics> usage = containerizer.get()->usage(containerId);
    AWAIT_READY(usage);

    ASSERT_TRUE(usage->has_disk_limit_bytes());
    EXPECT_EQ(Megabytes(3), Bytes(usage->disk_limit_bytes()));

    if (usage->has_disk_used_bytes()) {
      if (usage->disk_used_bytes() >= Megabytes(4).bytes()) {
        break;
      }
    }

    // The stopping condition for this test is that the isolator is
    // able to report that we wrote the full amount of data without
    // being constrained by the task disk limit.
    EXPECT_LE(usage->disk_used_bytes(), Megabytes(4).bytes());

    ASSERT_FALSE(timeout.expired())
      << "Used " << Bytes(usage->disk_used_bytes())
      << " of expected " << Megabytes(4)
      << " within the " << diskTimeout << " timeout";

    os::sleep(Milliseconds(100));
  }

//.........这里部分代码省略.........
开发者ID:janisz,项目名称:mesos,代码行数:101,代码来源:xfs_quota_tests.cpp

示例9: initApplication

void initApplication(void)
{
    unsigned int channels = currentVersion->noOfChannels;
    unsigned int longKeyTime = userEeprom.getUInt16(
            currentVersion->baseAddress + 2);
    unsigned int addressStartupDelay = currentVersion->baseAddress + 4 // debounce, longTime
            + channels * 46 + channels + (11 + channels) * 4 // logic config
            + 10;
    unsigned int busReturn = userEeprom.getUInt8(addressStartupDelay - 1) & 0x2; // bit offset is 6: means 2^(7-bit offset)
    memset(channelConfig, 0, sizeof(channelConfig));
    inputs.begin(channels, currentVersion->baseAddress);

    Timeout startupDelay;
    // delay in config is in seconds
    unsigned int delay = userEeprom.getUInt16(addressStartupDelay) * 1000;
    startupDelay.start(delay);
    if (delay)
    {
        while (!startupDelay.expired())
        {
            inputs.scan();
            for (int unsigned i = 0; i < currentVersion->noOfChannels; i++)
            {
                unsigned int value;
                inputs.checkInput(i, &value);
            }
            waitForInterrupt();
        }
    }


    unsigned int busReturnLogic = userEeprom.getUInt8(addressStartupDelay - 1) & 0x01;

    for (unsigned int i = 0; i < MAX_LOGIC; i++)
    {
        if (userEeprom.getUInt8(currentVersion->logicBaseAddress + i * (11 + channels))
                != 0xff)
        {
            logicConfig[i] = new Logic(currentVersion->logicBaseAddress, i,
                    channels, busReturnLogic);
        }
    }

    inputs.scan();
    for (unsigned int i = 0; i < channels; i++)
    {
        unsigned int value;
        int configBase = currentVersion->baseAddress + 4 + i * 46;
        word channelType = userEeprom.getUInt16(configBase);
        Channel * channel;
        inputs.checkInput(i, &value);
        //leds.setStatus(i, value);
        for (unsigned int n = 0; n < MAX_LOGIC; n++)
        {
            if (logicConfig[n])
            {
                logicConfig[n]->inputChanged(n, value);
            }
        }

        busReturn = userEeprom.getUInt8(configBase + 32) || userEeprom.getUInt8(addressStartupDelay - 1) & 0x02; // param sendValue || readToggleObject
        switch (channelType)
        {
        case 0: // channel is configured as switch
            channel = new Switch(i, longKeyTime, configBase, busReturn, value);
            break;
        case 256: // channel is configured as switch short/long
            channel = new Switch2Level(i, longKeyTime, configBase, busReturn,
                    value);
            break;
        case 1: // channel is configured as dimmer
            channel = new Dimmer(i, longKeyTime, configBase, busReturn, value);
            break;
        case 2: // channel is configured as jalo
            channel = new Jalo(i, longKeyTime, configBase, busReturn, value);
            break;
        case 3: // channel is configured as scene
            channel = new Scene(i, longKeyTime, configBase, busReturn, value);
            break;
        case 4: // channel is configured as counter
            channel = new Counter(i, longKeyTime, configBase, busReturn, value);
            break;
        case 511: // channel is configured as LED output
        	channel = new LedOutput(i, longKeyTime, configBase, busReturn, value);
            break;
        default:
            channel = 0;
        }
        channelConfig[i] = channel;
    }

}
开发者ID:selfbus,项目名称:software-arm-incubation,代码行数:92,代码来源:app_in.cpp

示例10: _check_expired_yes

static void _check_expired_yes(void * refState)
{
	REQUIRE(to.expired() == true);
	REQUIRE(to.started() == false);
	REQUIRE(to.stopped() == true);
}
开发者ID:glueckm,项目名称:software-arm-incubation,代码行数:6,代码来源:timeout_test.cpp


注:本文中的Timeout::expired方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。