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


C++ Timestamp函数代码示例

本文整理汇总了C++中Timestamp函数的典型用法代码示例。如果您正苦于以下问题:C++ Timestamp函数的具体用法?C++ Timestamp怎么用?C++ Timestamp使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: printf

void
MainWin::Play() {
    printf("Playing.\n");

    if (sp && sp->HasData()) {
        sp->Start();
        return;
    }

    printf("Starting at position %d.\n", (int) position);

    status_t err;

    LibraryItem *item = dynamic_cast<LibraryItem *>(be_app->library->list->ItemAt(position));
    printf("Playing track %s.\n", item->entry.name);

    mediaFile = new BMediaFile(&item->entry);
    if ((err = mediaFile->InitCheck()) != B_OK) {
        printf("Play: Initiating media file failed: %s; skipping.\n", strerror(err));
        delete mediaFile;
        Next();
        return;
    }

    playTrack = 0;
    for (int i = 0; i < mediaFile->CountTracks(); i++) {
        playTrack = mediaFile->TrackAt(i);
        playFormat.type = B_MEDIA_RAW_AUDIO;

        if (playTrack->DecodedFormat(&playFormat) == B_OK)
            break;

        if (playTrack)
            mediaFile->ReleaseTrack(playTrack);
    }

    if (playTrack) {
        sp = new BSoundPlayer(&playFormat.u.raw_audio, "playfile", PlayBuffer, Notifier);
        sp->SetCookie(this);
        sp->SetVolume(1.0f);
        sp->SetHasData(true);
        sp->Start();

        char timestamp[100];
        Timestamp(timestamp, playTrack->Duration());

        progress->Reset(NULL, timestamp);
        progress->SetMaxValue(playTrack->Duration());

        BMessage *select = new BMessage(MSG_LIBRARY_HIGHLIGHT);
        select->AddUInt32("position", position);

        be_app->library->PostMessage(select);

        printf("Playback started.\n");
    } else {
        printf("ERROR: No valid track found. Skipping.\n");
        Next();
    }
}
开发者ID:vito,项目名称:MusicPlayer,代码行数:60,代码来源:MainWin.cpp

示例2: catch

bool Condition::safeWait(const Mutex& mutex, double seconds) const {
  bool result = true;
  Thread* self = 0;
  try {
    self = &Threads::getInstance().getSelf();
  }
  catch (...) {
    self = 0;
  }
  Thread::State threadState;
  if (self) {
    if (&mutex == &self->mMutex)
      threadState = self->safeSetState(Thread::waiting);
    else 
      threadState = self->setState(Thread::waiting);
  }
  if (seconds == Timer::eternal())
    result = safeEternalWait(mutex);
  else if (seconds > 0.0)
    result = safeWaitUntil(mutex, Timestamp(Timestamp::now() + seconds));
  if (self) {
    if (&mutex == &self->mMutex)
      self->safeSetState(threadState);
    else 
      self->setState(threadState);
  }
  return result;
}
开发者ID:ethz-asl,项目名称:mv_cameras_ros,代码行数:28,代码来源:Condition.cpp

示例3: _testOplogEntryIsForCappedCollection

bool _testOplogEntryIsForCappedCollection(OperationContext* txn,
                                          const NamespaceString& nss,
                                          const CollectionOptions& options) {
    auto writerPool = SyncTail::makeWriterPool();
    MultiApplier::Operations operationsApplied;
    auto applyOperationFn = [&operationsApplied](MultiApplier::OperationPtrs* operationsToApply) {
        for (auto&& opPtr : *operationsToApply) {
            operationsApplied.push_back(*opPtr);
        }
    };
    createCollection(txn, nss, options);

    auto op = makeInsertDocumentOplogEntry({Timestamp(Seconds(1), 0), 1LL}, nss, BSON("a" << 1));
    ASSERT_FALSE(op.isForCappedCollection);

    auto lastOpTime =
        unittest::assertGet(multiApply(txn, writerPool.get(), {op}, applyOperationFn));
    ASSERT_EQUALS(op.getOpTime(), lastOpTime);

    ASSERT_EQUALS(1U, operationsApplied.size());
    const auto& opApplied = operationsApplied.front();
    ASSERT_EQUALS(op, opApplied);
    // "isForCappedCollection" is not parsed from raw oplog entry document.
    return opApplied.isForCappedCollection;
}
开发者ID:DreamerKing,项目名称:mongo,代码行数:25,代码来源:sync_tail_test.cpp

示例4: TEST_F

TEST_F(SyncTailTest, MultiApplyReturnsBadValueOnNullOperationContext) {
    auto writerPool = SyncTail::makeWriterPool();
    auto op = makeCreateCollectionOplogEntry({Timestamp(Seconds(1), 0), 1LL});
    auto status = multiApply(nullptr, writerPool.get(), {op}, noopApplyOperationFn).getStatus();
    ASSERT_EQUALS(ErrorCodes::BadValue, status);
    ASSERT_STRING_CONTAINS(status.reason(), "invalid operation context");
}
开发者ID:DreamerKing,项目名称:mongo,代码行数:7,代码来源:sync_tail_test.cpp

示例5: _inStream

Mp3PspStream::Mp3PspStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag dispose) :
	_inStream(inStream),
	_disposeAfterUse(dispose),
	_pcmLength(0),
	_posInFrame(0),
	_state(MP3_STATE_INIT),
	_length(0, 1000),
	_sampleRate(0),
	_totalTime(mad_timer_zero) {

	DEBUG_ENTER_FUNC();

	assert(_decoderInit);	// must be initialized by now

	// let's leave the buffer guard -- who knows, it may be good?
	memset(_buf, 0, sizeof(_buf));
	memset(_codecInBuffer, 0, sizeof(_codecInBuffer));

	initStream();	// init needed stuff for the stream

	findValidHeader();	// get a first header so we can read basic stuff

	_sampleRate = _header.samplerate;	// copy it before it gets destroyed
	_stereo = (MAD_NCHANNELS(&_header) == 2);

	while (_state != MP3_STATE_EOS)
		findValidHeader();	// get a first header so we can read basic stuff

	_length = Timestamp(mad_timer_count(_totalTime, MAD_UNITS_MILLISECONDS), getRate());

	deinitStream();

	_state = MP3_STATE_INIT;
}
开发者ID:bgK,项目名称:scummvm,代码行数:34,代码来源:mp3.cpp

示例6: TEST_F

TEST_F(KeysManagerShardedTest, GetKeyForValidationErrorsIfKeyDoesntExist) {
    keyManager()->startMonitoring(getServiceContext());

    auto keyStatus =
        keyManager()->getKeyForValidation(operationContext(), 1, LogicalTime(Timestamp(100, 0)));
    ASSERT_EQ(ErrorCodes::KeyNotFound, keyStatus.getStatus());
}
开发者ID:i80and,项目名称:mongo,代码行数:7,代码来源:keys_collection_manager_sharding_test.cpp

示例7: maPtr

void testObj::test<6>(void)
{
  Persistency::MetaAlertPtrNN maPtr( new Persistency::MetaAlert( Persistency::MetaAlert::Name(name_),
                                                                 0.1, 0.2,
                                                                 makeNewReferenceURL().shared_ptr(),
                                                                 Timestamp(),
                                                                 42u ) );
  Persistency::IO::Postgres::MetaAlert malert(maPtr, t_, dbh_);
  malert.save();
  const  DataBaseID malertID = dbh_->getIDCache()->get( maPtr );
  double delta = 0.1;
  stringstream ss;
  ss << "SELECT * FROM meta_alerts WHERE id = " << malertID << ";";
  {
    const result r = t_.getAPI<TransactionAPI>().exec(ss);
    ensure_equals("invalid size",r.size(), 1u);
    ensure_equals("invalid certainty delta", ReaderHelper<double>::readAsNotNull(r[0]["certainty_delta"]), 0.2);
  }
  malert.updateCertaintyDelta(delta);
  {
    const result r = t_.getAPI<TransactionAPI>().exec(ss);
    ensure_equals("invalid size",r.size(), 1u);
    ensure("invalid certainty delta",
           ( ReaderHelper<double>::readAsNotNull(r[0]["certainty_delta"]) - (0.2+delta) ) < 0.01 );
  }
  t_.commit();
}
开发者ID:el-bart,项目名称:ACARM-ng,代码行数:27,代码来源:MetaAlert.t.cpp

示例8: Date_t

Status ModifierCurrentDate::apply() const {
    const bool destExists = (_preparedState->elemFound.ok() &&
                             _preparedState->idxFound == (_updatePath.numParts() - 1));

    mutablebson::Document& doc = _preparedState->doc;
    StringData lastPart = _updatePath.getPart(_updatePath.numParts() - 1);
    // If the element exists and is the same type, then that is what we want to work with
    mutablebson::Element elemToSet = destExists ? _preparedState->elemFound : doc.end();

    if (!destExists) {
        // Creates the final element that's going to be $set in 'doc'.
        // fills in the value with place-holder/empty

        elemToSet = _typeIsDate ? doc.makeElementDate(lastPart, Date_t())
                                : doc.makeElementTimestamp(lastPart, Timestamp());

        if (!elemToSet.ok()) {
            return Status(ErrorCodes::InternalError, "can't create new element");
        }

        // Now, we can be in two cases here, as far as attaching the element being set goes:
        // (a) none of the parts in the element's path exist, or (b) some parts of the path
        // exist but not all.
        if (!_preparedState->elemFound.ok()) {
            _preparedState->elemFound = doc.root();
            _preparedState->idxFound = 0;
        } else {
            _preparedState->idxFound++;
        }

        // createPathAt() will complete the path and attach 'elemToSet' at the end of it.
        Status s = pathsupport::createPathAt(
                       _updatePath, _preparedState->idxFound, _preparedState->elemFound, elemToSet)
                       .getStatus();
        if (!s.isOK())
            return s;
    }

    dassert(elemToSet.ok());

    // By the time we are here the element is in place and we just need to update the value
    if (_typeIsDate) {
        const mongo::Date_t now = mongo::jsTime();
        Status s = elemToSet.setValueDate(now);
        if (!s.isOK())
            return s;
    } else {
        ServiceContext* service = getGlobalServiceContext();
        auto ts = LogicalClock::get(service)->reserveTicks(1).asTimestamp();
        Status s = elemToSet.setValueTimestamp(ts);
        if (!s.isOK())
            return s;
    }

    // Set the elemFound, idxFound to the changed element for oplog logging.
    _preparedState->elemFound = elemToSet;
    _preparedState->idxFound = (_updatePath.numParts() - 1);

    return Status::OK();
}
开发者ID:DINKIN,项目名称:mongo,代码行数:60,代码来源:modifier_current_date.cpp

示例9: sclock

	void PeersManager::dumpConnectionMap()
	{
		// 这里上锁仅仅是为了锁住对ApplicationData的访问
		cacti::RecursiveMutex::ScopedLock sclock(m_applock);

		m_connMap.info("\n%s:\n", 
			Timestamp::getNowTime().getFormattedTime("%m%d %H:%M:%S").c_str());

		std::map<u32, ApplicationData>::iterator it = m_applications.begin();
		while(it != m_applications.end())
		{
			ApplicationData& ad = it->second;
			m_connMap.info("[%d, %s] \n", 
				ad.m_appid, ad.m_appName.c_str());
			m_connMap.info("\t addr=%s|%s:%d\n", 
				ad.m_primAddress.c_str(), ad.m_backAddress.c_str(), ad.m_connectPort);
			m_connMap.info("\t pasv=%08X\n", ad.m_passiveConnection);
			m_connMap.info("\t svrs=");
			u32 starttime = 0;
			for(size_t i=0; i<ad.m_activeServices.size(); ++i)
			{
				m_connMap.info("%d ", ad.m_activeServices[i]);
				starttime = ad.m_starttimes[ad.m_activeServices[i]];
			}
			m_connMap.info("\n\t boot timestamp:%s\n", Timestamp((time_t)starttime).getFormattedTime("%Y%m%d %H:%M:%S").c_str());
			++it;
		}

		// check anonymous
		for(size_t i=0; i<m_anonymousApps.size(); ++i)
		{
			ApplicationData& ad = m_anonymousApps[i];
			m_connMap.info("[%d, %s] \n", 
				ad.m_appid, ad.m_appName.c_str());
			m_connMap.info("\t addr=%s|%s:%d\n", 
				ad.m_primAddress.c_str(), ad.m_backAddress.c_str(), ad.m_connectPort);
			m_connMap.info("\t pasv=%08X\n", ad.m_passiveConnection);
			m_connMap.info("\t svrs=");
			u32 starttime = 0;
			for(size_t i=0; i<ad.m_activeServices.size(); ++i)
			{
				m_connMap.info("%d ", ad.m_activeServices[i]);
				starttime = ad.m_starttimes[ad.m_activeServices[i]];
			}
			m_connMap.info("\n\t boot timestamp:%s\n", Timestamp((time_t)starttime).getFormattedTime("%Y%m%d %H:%M:%S").c_str());
		}
	}
开发者ID:jinby,项目名称:autoupdate,代码行数:47,代码来源:PeersManager.cpp

示例10: TEST_F

TEST_F(OplogBufferCollectionTest, extractEmbeddedOplogDocumentChangesIdToTimestamp) {
    auto nss = makeNamespace(_agent);
    OplogBufferCollection oplogBuffer(_storageInterface, nss);

    const BSONObj expectedOp = makeOplogEntry(1);
    BSONObj originalOp = BSON("_id" << Timestamp(1, 1) << "entry" << expectedOp);
    ASSERT_BSONOBJ_EQ(expectedOp, OplogBufferCollection::extractEmbeddedOplogDocument(originalOp));
}
开发者ID:hgGeorg,项目名称:mongo,代码行数:8,代码来源:oplog_buffer_collection_test.cpp

示例11: TEST_F

TEST_F(KeyGeneratorUpdateTest, ShouldCreateAnotherKeyIfOnlyOneKeyExists) {
    KeyGenerator generator("dummy", catalogClient(), Seconds(5));

    LogicalClock::get(operationContext())
        ->setClusterTimeFromTrustedSource(LogicalTime(Timestamp(100, 2)));

    KeysCollectionDocument origKey1(
        1, "dummy", TimeProofService::generateRandomKey(), LogicalTime(Timestamp(105, 0)));
    ASSERT_OK(insertToConfigCollection(
        operationContext(), KeysCollectionDocument::ConfigNS, origKey1.toBSON()));

    {
        auto allKeys = getKeys(operationContext());

        ASSERT_EQ(1u, allKeys.size());

        const auto& key1 = allKeys.front();
        ASSERT_EQ(1, key1.getKeyId());
        ASSERT_EQ("dummy", key1.getPurpose());
        ASSERT_EQ(Timestamp(105, 0), key1.getExpiresAt().asTimestamp());
    }

    auto currentTime = LogicalClock::get(operationContext())->getClusterTime();

    auto generateStatus = generator.generateNewKeysIfNeeded(operationContext());
    ASSERT_OK(generateStatus);

    {
        auto allKeys = getKeys(operationContext());

        ASSERT_EQ(2u, allKeys.size());

        const auto& key1 = allKeys.front();
        ASSERT_EQ(1, key1.getKeyId());
        ASSERT_EQ("dummy", key1.getPurpose());
        ASSERT_EQ(origKey1.getKey(), key1.getKey());
        ASSERT_EQ(Timestamp(105, 0), key1.getExpiresAt().asTimestamp());

        const auto& key2 = allKeys.back();
        ASSERT_EQ(currentTime.asTimestamp().asLL(), key2.getKeyId());
        ASSERT_EQ("dummy", key2.getPurpose());
        ASSERT_EQ(Timestamp(110, 0), key2.getExpiresAt().asTimestamp());

        ASSERT_NE(key1.getKey(), key2.getKey());
    }
}
开发者ID:asya999,项目名称:mongo,代码行数:46,代码来源:key_generator_update_test.cpp

示例12: makeNewMetaAlert

MetaAlertPtrNN makeNewMetaAlert(const char *name, const unsigned int id)
{
  return MetaAlertPtrNN( new MetaAlert( MetaAlert::Name(name),
                                        0.1, 0.2,
                                        makeNewReferenceURL().shared_ptr(),
                                        Timestamp(),
                                        id ) );
}
开发者ID:el-bart,项目名称:ACARM-ng,代码行数:8,代码来源:TestHelpers.cpp

示例13: getNextGlobalTimestamp

Timestamp getNextGlobalTimestamp() {
    stdx::lock_guard<stdx::mutex> lk(globalTimestampMutex);

    const unsigned now = (unsigned)time(0);
    const unsigned globalSecs = globalTimestamp.getSecs();
    if (globalSecs == now) {
        globalTimestamp = Timestamp(globalSecs, globalTimestamp.getInc() + 1);
    } else if (now < globalSecs) {
        globalTimestamp = Timestamp(globalSecs, globalTimestamp.getInc() + 1);
        // separate function to keep out of the hot code path
        fassert(17449, !skewed(globalTimestamp));
    } else {
        globalTimestamp = Timestamp(now, 1);
    }

    return globalTimestamp;
}
开发者ID:stevelyall,项目名称:mongol-db,代码行数:17,代码来源:global_timestamp.cpp

示例14: gettimeofday

Timestamp Timestamp::now()
{
  struct timeval tv;
  gettimeofday(&tv, NULL);
  time_t seconds = tv.tv_sec;
  
  return Timestamp(seconds * kAccuracyPerSecond + tv.tv_usec);
}
开发者ID:ubuntu-chu,项目名称:project_sensor,代码行数:8,代码来源:timestamp.cpp

示例15: TEST_F

TEST_F(KeysManagerShardedTest, GetKeyForValidationTimesOutIfRefresherIsNotRunning) {
    operationContext()->setDeadlineAfterNowBy(Microseconds(250 * 1000),
                                              ErrorCodes::ExceededTimeLimit);

    ASSERT_THROWS(
        keyManager()->getKeyForValidation(operationContext(), 1, LogicalTime(Timestamp(100, 0))),
        DBException);
}
开发者ID:ShaneHarvey,项目名称:mongo,代码行数:8,代码来源:keys_collection_manager_sharding_test.cpp


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