本文整理汇总了C++中milliseconds类的典型用法代码示例。如果您正苦于以下问题:C++ milliseconds类的具体用法?C++ milliseconds怎么用?C++ milliseconds使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了milliseconds类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ReadImage
Image ReadImage(tjhandle tj, int width, int height, int quality = 75) {
static std::vector< char > img;
static int count = 0;
img.resize(3 * width * height);
glReadBuffer(GL_FRONT);
#ifdef TIME_READPIXEL
using namespace std::chrono;
steady_clock::time_point t = steady_clock::now();
#endif
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, &img[0]);
#ifdef TIME_READPIXEL
const milliseconds E =
duration_cast< milliseconds >(steady_clock::now() - t);
cout << E.count() << ' '; //doesn't flush, prints after closing window
#endif
char* out = nullptr;
unsigned long size = 0;
tjCompress2(tj,
(unsigned char*) &img[0],
width,
3 * width,
height,
TJPF_RGB,
(unsigned char **) &out,
&size,
TJSAMP_444,
quality,
0);
return Image(ImagePtr((char*) out, TJDeleter()), size, count++);
}
开发者ID:candycode,项目名称:websocketsplus,代码行数:32,代码来源:gl-stream-async-jpg.cpp
示例2: addFunctionUniformDistribution
void FunctionScheduler::addFunctionUniformDistribution(
Function<void()>&& cb,
milliseconds minInterval,
milliseconds maxInterval,
StringPiece nameID,
milliseconds startDelay) {
addFunctionGenericDistribution(
std::move(cb),
UniformDistributionFunctor(minInterval, maxInterval),
nameID.str(),
to<std::string>(
"[", minInterval.count(), " , ", maxInterval.count(), "] ms"),
startDelay);
}
开发者ID:1Hgm,项目名称:folly,代码行数:14,代码来源:FunctionScheduler.cpp
示例3: set_timeout
void SocketImpl::set_timeout( const milliseconds& value )
{
tcp::socket::native_handle_type native_socket(0);
#ifdef BUILD_SSL
if ( m_socket not_eq nullptr )
{
#endif
native_socket = m_socket->native_handle( );
#ifdef BUILD_SSL
}
else
{
native_socket = m_ssl_socket->lowest_layer( ).native_handle( );
}
#endif
struct timeval timeout = { 0, 0 };
timeout.tv_usec = static_cast< long >( value.count( ) * 1000 );
int status = setsockopt( native_socket, SOL_SOCKET, SO_SNDTIMEO, reinterpret_cast< char* >( &timeout ), sizeof( timeout ) );
if ( status == -1 and m_logger not_eq nullptr )
{
m_logger->log( Logger::Level::WARNING, "Failed to set socket option, send timeout." );
}
status = setsockopt( native_socket, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast< char* >( &timeout ), sizeof( timeout ) );
if ( status == -1 and m_logger not_eq nullptr )
{
m_logger->log( Logger::Level::WARNING, "Failed to set socket option, receive timeout." );
}
}
开发者ID:narayantalk2u,项目名称:restbed,代码行数:35,代码来源:socket_impl.cpp
示例4: addFunction
void FunctionScheduler::addFunction(Function<void()>&& cb,
milliseconds interval,
StringPiece nameID,
milliseconds startDelay) {
addFunctionGenericDistribution(
std::move(cb),
ConstIntervalFunctor(interval),
nameID.str(),
to<std::string>(interval.count(), "ms"),
startDelay);
}
开发者ID:1Hgm,项目名称:folly,代码行数:11,代码来源:FunctionScheduler.cpp
示例5: mLogger
log_entry::log_entry(logger& l, logger::LogLevel level):
mLogger(l),
mLevel(level)
{
if(mLevel < 0) return;
using namespace std::chrono;
const milliseconds ms = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
const seconds s = duration_cast<seconds>(ms);
const std::time_t t = s.count();
const std::size_t fractional_seconds = ms.count() % 1000;
mLogger.lock();
const char timeFormat[] = "%Y-%m-%d %H:%M:%S";
const size_t buffSize = 100;
char buff[buffSize];
if(0 != std::strftime(buff, buffSize, timeFormat, std::localtime(&t)))
{
mLogger.get() << buff;
}
else
{
size_t dBuffSize = buffSize;
std::unique_ptr<char[]> dbuff;
do
{
dBuffSize *= 2;
dbuff.reset(new char[dBuffSize]);
}
while(0 == std::strftime(dbuff.get(), dBuffSize, timeFormat, std::localtime(&t)));
mLogger.get() << dbuff.get();
}
mLogger.get() << '.' << fractional_seconds << " ";
if(level >= 0 && level <= logger::logDEBUG)
{
const char* levels[] = {"ERROR","WARNING","INFO","DEBUG"};
mLogger.get() << levels[level];
}
mLogger.get() << ": ";
}
开发者ID:Hardcode84,项目名称:DirectDrawWrapper,代码行数:40,代码来源:logger.cpp
示例6: dist
bool
WeightedLoadBalancerStrategy::mySendInterest(const Interest& interest,
shared_ptr<MyMeasurementInfo>& measurementsEntryInfo,
shared_ptr<pit::Entry>& pitEntry)
{
typedef MyMeasurementInfo::WeightedFaceSetByDelay WeightedFaceSetByDelay;
const WeightedFaceSetByDelay& facesByDelay =
measurementsEntryInfo->weightedFaces.get<MyMeasurementInfo::ByDelay>();
const milliseconds totalDelay = measurementsEntryInfo->totalDelay;
const milliseconds inverseTotalDelay =
MyMeasurementInfo::calculateInverseDelaySum(measurementsEntryInfo);
boost::random::uniform_int_distribution<> dist(0, inverseTotalDelay.count());
const uint64_t selection = dist(m_randomGenerator);
NFD_LOG_TRACE("selection = " << selection);
uint64_t cumulativeWeight = 0;
for (WeightedFaceSetByDelay::const_iterator i = facesByDelay.begin();
i != facesByDelay.end();
++i)
{
NFD_LOG_TRACE("cumulative weight = " << cumulativeWeight);
// weight = inverted delay measurement
const uint64_t weight = totalDelay.count() - i->lastDelay.count();
cumulativeWeight += weight;
if(selection <= cumulativeWeight && pitEntry->canForwardTo(i->face))
{
NFD_LOG_TRACE("fowarding " << interest.getName() << " out face " << i->face.getId());
this->sendInterest(pitEntry, this->getFace(i->face.getId()));
return true;
}
}
return false;
}
开发者ID:dibenede,项目名称:ndn-tutorial-gec21,代码行数:40,代码来源:weighted-load-balancer-strategy.cpp
示例7: ReadImage
Image ReadImage(int width, int height,
float quality = 100) {
static std::vector< char > img;
static int count = 0;
img.resize(3 * width * height);
glReadBuffer(GL_FRONT);
#ifdef TIME_READPIXEL
using namespace std::chrono;
steady_clock::time_point t = steady_clock::now();
#endif
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, &img[0]);
#ifdef TIME_READPIXEL
const milliseconds E =
duration_cast< milliseconds >(steady_clock::now() - t);
cout << E.count() << ' '; //doesn't flush, prints after closing window
#endif
uint8_t* out;
const size_t size =
WebPEncodeRGB((uint8_t*) &img[0], width, height, 3 * width,
quality, &out);
return Image(ImagePtr((char*) out, WebpDeleter()), size, count++);
}
开发者ID:candycode,项目名称:websocketsplus,代码行数:22,代码来源:gl-stream-async.cpp
示例8: update
void Transition::update(milliseconds elapsed)
{
switch (state_)
{
case State::empty:
case State::full:
return;
case State::increase:
progress_ += static_cast<float>(elapsed.count()) / time_to_complete_.count();
if (progress_ >= 1.0f) {
progress_ = 1.0f;
state_ = State::full;
}
break;
case State::decrease:
progress_ -= static_cast<float>(elapsed.count()) / time_to_complete_.count();
if (progress_ <= 0.0f) {
progress_ = 0.0f;
state_ = State::empty;
}
break;
}
}
开发者ID:joemasterjohn,项目名称:medleap,代码行数:23,代码来源:Transition.cpp
示例9: interval
void AppState::initTimerEngine() {
const milliseconds interval(1);
const milliseconds dueTime(0);
//创建定时器,无属性,自动复位,匿名
HANDLE handle = CreateWaitableTimer(NULL, FALSE, NULL);
LARGE_INTEGER liDueTime;
liDueTime.QuadPart = -(nanoseconds(dueTime).count() / 100);
if (!SetWaitableTimer(handle, &liDueTime, interval.count(), NULL, NULL, FALSE)) {
throw std::runtime_error("dispatcherTimerEngine init error!");
}
DispatcherTimerEngine& engine = DispatcherTimerEngine::instance();
engine.setInterval(interval);
engine.start(dueTime);
//添加等待对象,以及触发事件
addEventHandle(handle, std::bind(&DispatcherTimerEngine::update, &engine));
}
开发者ID:sy-yanghuan,项目名称:Matrix,代码行数:21,代码来源:win_app.cpp
示例10: output
void SimpleThinkingWriter::output(const ChessBoard& board,
const SearchResult& result,
const vector<Move>& main_variation,
const int nodes,
const milliseconds& time,
const Searcher::depth_t depth)
{
if (!post()) {
return;
}
ostringstream oss;
int turn_number = board.turn_number();
int ply = 0;
if (board.turn_color() == Color::Black) {
oss << turn_number << ". ... ";
++turn_number;
++ply;
}
for (const Move move : main_variation) {
if (ply % 2 == 0) {
oss << " " << turn_number << ".";
++turn_number;
}
oss << " " << move.source() << move.destination();
if (move.is_promotion()) {
oss << PieceSet::instance().piece(move.created_piece()).symbol(Color::Black);
}
++ply;
}
const int score = board.turn_color() == Color::White ? result.score : -result.score;
m_writer->thinking_output(depth,
score,
time.count() / 10,
nodes,
oss.str());
} // namespace olaf
开发者ID:Lykos,项目名称:Olaf,代码行数:37,代码来源:simplethinkingwriter.cpp
示例11: set_resend_interval
void set_resend_interval(socket &s, milliseconds i)
{ s.setopt(REQ, REQ_RESEND_IVL, static_cast<int>(i.count())); }
开发者ID:Bigpet,项目名称:nanomsgxx,代码行数:2,代码来源:reqrep.cpp
示例12: AppState
//.........这里部分代码省略.........
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
void AppState::initWindow() {
const wchar_t WINDOW_CLASS_NAME[] = L"Sample Window Class";
WNDCLASSW wc = { };
wc.lpfnWndProc = windowProc;
wc.hInstance = hInstance_;
wc.lpszClassName = WINDOW_CLASS_NAME;
if (!RegisterClassW(&wc)) {
throw std::runtime_error("RegisterClassW error!");
}
windowHwnd = CreateWindowExW(
0, // Optional window styles.
WINDOW_CLASS_NAME, // Window class
L"dddd", //Window Title
WS_OVERLAPPEDWINDOW, // Window style
// Size and position
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, // Parent window
NULL, // Menu
hInstance_, // Instance handle
NULL // Additional application data
);
if (!windowHwnd) {
throw std::runtime_error("CreateWindowExW error!");
}
}
void AppState::initTimerEngine() {
const milliseconds interval(1);
const milliseconds dueTime(0);
//创建定时器,无属性,自动复位,匿名
HANDLE handle = CreateWaitableTimer(NULL, FALSE, NULL);
LARGE_INTEGER liDueTime;
liDueTime.QuadPart = -(nanoseconds(dueTime).count() / 100);
if (!SetWaitableTimer(handle, &liDueTime, interval.count(), NULL, NULL, FALSE)) {
throw std::runtime_error("dispatcherTimerEngine init error!");
}
DispatcherTimerEngine& engine = DispatcherTimerEngine::instance();
engine.setInterval(interval);
engine.start(dueTime);
//添加等待对象,以及触发事件
addEventHandle(handle, std::bind(&DispatcherTimerEngine::update, &engine));
}
void AppState::initInputDevices() {
//创建DirectInput8对象
IDirectInput8A* direct_input;
dx::throwIfFailed(
DirectInput8Create(
hInstance_,
DIRECTINPUT_VERSION,
IID_IDirectInput8,
(void **) &direct_input,
nullptr)
);
direct_input_.reset(direct_input);
开发者ID:sy-yanghuan,项目名称:Matrix,代码行数:67,代码来源:win_app.cpp
示例13: sleep_for
void sleep_for(milliseconds d) {
// usleep is nanoseconds.
usleep (d.count() * 1000);
}
开发者ID:TellarHK,项目名称:wwiv,代码行数:4,代码来源:os_unix.cpp
示例14:
Timer::Timer(milliseconds expiration_time, bool start_active) :
current_time_{ start_active ? 0 : expiration_time.count() + 1},
expiration_time_{expiration_time}
{
timers_.insert(this);
}
开发者ID:ChunHungLiu,项目名称:cavestory-sdl2,代码行数:6,代码来源:timer.cpp
示例15: onTimer
void PoolingAcceptor::onTimer(const milliseconds& delta) {
LOG(INFO)<< "[" << __FUNCTION__ << "] " << delta.count();
}
开发者ID:paulina-szubarczyk,项目名称:Tanki,代码行数:3,代码来源:PoolingAcceptor.cpp
示例16: abs
milliseconds abs(const milliseconds& t) {
return milliseconds(abs(t.count()));
}
开发者ID:gyengep,项目名称:irrigation,代码行数:3,代码来源:ChronoTools.cpp
示例17: assert
void TimedAxisController::setInterval(unsigned int interval)
{
assert(interval < MAX_MILLI.count());
this->interval = milliseconds(interval);
}
开发者ID:ESE-Semester5,项目名称:MobilePlatformController,代码行数:5,代码来源:timedaxiscontroller.cpp
示例18: main
//.........这里部分代码省略.........
//texture coordinate buffer
GLuint texbo;
glGenBuffers(1, &texbo);
glBindBuffer(GL_ARRAY_BUFFER, texbo);
glBufferData(GL_ARRAY_BUFFER, 12 * sizeof(real_t),
&texcoord[0], GL_STATIC_DRAW);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
// create texture
std::vector< float > tc(SIZE * SIZE, 0.5f);
GLuint tex;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RED,
SIZE,
SIZE,
0,
GL_RED,
GL_FLOAT,
&tc[0]);
//optional
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
//required
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);
//OPENGL RENDERING SHADERS
GLuint glprogram = create_program(vertexShaderSrc, fragmentShaderSrc);
//enable gl program
glUseProgram(glprogram);
//extract ids of shader variables
GLint mvpID = glGetUniformLocation(glprogram, "MVP");
GLint textureID = glGetUniformLocation(glprogram, "cltexture");
GLint frameID = glGetUniformLocation(glprogram, "frame");
//only need texture unit 0
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex);
glUniform1i(textureID, 0);
//beckground color
glClearColor(0.0f, 0.0f, 0.4f, 0.0f);
//RENDER LOOP
//rendering & simulation loop
UserData data(vao, quadvbo, texbo, mvpID, frameID, context, 0);
glfwSetWindowUserPointer(window, &data);
int width = 0;
int height = 0;
using namespace std::chrono;
const milliseconds T(20);
while (!glfwWindowShouldClose(window)) {
steady_clock::time_point t = steady_clock::now();
glfwGetFramebufferSize(window, &width, &height);
Draw(window, data, width, height);
glfwSwapBuffers(window);
data.context->SetServiceDataSync(ReadImage(tj, width, height, 100));
++data.frame;
const milliseconds E =
duration_cast< milliseconds >(steady_clock::now() - t);
#ifdef TIME_RENDER_STEP
cout << E.count() << ' ';
#endif
std::this_thread::sleep_for(
max(duration_values<milliseconds>::zero(), T - E));
glfwPollEvents();
}
//CLEANUP
glDeleteBuffers(1, &quadvbo);
glDeleteBuffers(1, &texbo);
glDeleteTextures(1, &tex);
glfwDestroyWindow(window);
glfwTerminate();
is.wait();
tjDestroy(tj);
exit(EXIT_SUCCESS);
return 0;
}
开发者ID:candycode,项目名称:websocketsplus,代码行数:101,代码来源:gl-stream-async-jpg.cpp
示例19: main
int main(int argc, char **argv)
{
if (argc < 4) {
puts("Usage: ./out $num_passengers $capacity $time_interval $cycles");
exit(1);
}
int num_passengers = stoi(argv[1]),
capacity = stoi(argv[2]),
time_interval = stoi(argv[3]),
cycles = stoi(argv[4]);
pthread_t passenger_threads[num_passengers];
pthread_t coaster_thread;
s = high_resolution_clock::now();
RollerCoaster coaster_car = RollerCoaster(capacity, time_interval, cycles);
Passenger* passengers[num_passengers];
pthread_create(&coaster_thread, NULL, roller_coaster, (void*) &coaster_car);
for (int i = 0; i < num_passengers; ++i) {
passengers[i] = new Passenger(i + 1, coaster_car);
pthread_create(&passenger_threads[i], NULL, passenger, (void*) passengers[i]);
}
for (int i = 0; i < num_passengers; ++i) pthread_join(passenger_threads[i], NULL);
pthread_join(coaster_thread, NULL);
cout << "Total waiting time of all passengers: " << wait_time.count() << " millisec\n";
return 0;
}
开发者ID:leVirve,项目名称:N-Body-Simulation,代码行数:29,代码来源:roller-coaster.cpp
注:本文中的milliseconds类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论