- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我们正在尝试在 Android 设备上使用 boost asio deadline_timers。我们有一个要求,我们需要每 100 毫秒触发一个定时器。我使用了如下代码。但是,计时器似乎每 1 秒触发一次。我们应该在 Android 系统中进行哪些微调才能使 boost asio 截止时间计时器按预期工作?
注意:以下代码在普通 linux 系统上按预期工作。是什么让它在 Andorid 系统上的工作方式不同?
代码:
void print(asio::deadline_timer* ptimer, const asio::error_code& err)
{
struct timeval tval;
if(0 == gettimeofday(&tval, NULL))
{
std::cout <<" Timer... sec::microsec = "<<tval.tv_sec<<"::"<<tval.tv_usec<< std::endl;
}
else
{
std::cout <<" Timer... gettimeofday Error!" << std::endl;
}
ptimer->expires_from_now(boost::posix_time::milliseconds(100));
ptimer->async_wait(boost::bind(&print, ptimer, asio::placeholders::error));
}
Android 设备上的输出
Timer... sec::microsec = 1298328679::39207
Timer... sec::microsec = 1298328680::46773
Timer... sec::microsec = 1298328681::54624
Timer... sec::microsec = 1298328682::63861
Timer... sec::microsec = 1298328683::65740
Timer... sec::microsec = 1298328684::69301
Timer... sec::microsec = 1298328685::76500
Timer... sec::microsec = 1298328686::85768
最佳答案
您可能想确保您的 Android 环境最终定义了BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK。
如果您查看 boost/asio/time_traits.hpp
中的默认 timer_traits,您会发现如果未定义,asio 将使用 second_clock 作为它的计时器。
此定义来自 boost/date_time/compiler_config.hpp
,以 BOOST_HAS_GETTIMEOFDAY 或 BOOST_HAS_FTIME 为条件。鉴于您的示例,大概应该定义前者。
不知道是android算作自己的平台还是boost检测为linux。在 boost/config/platform/linux.hpp
中定义为:
//// If glibc is past version 2 then we definitely have// gettimeofday, earlier versions may or may not have it://#if defined(__GLIBC__) && (__GLIBC__ >= 2)# define BOOST_HAS_GETTIMEOFDAY#endif
这可能是您要为 android 添加附加条件的地方。
关于android - Android 设备上的 Boost Asio deadline_timer 不会在到期时间触发,而是在稍后的时间触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4777998/
通过Dropbox oAuth2 API获取的访问 token 的生存期是多少? https://api.dropbox.com/1/oauth2/token之后的答案类似于 { "acces
在 Braintree 中,当我生成带有 $customerId 的客户端 token 时,将该客户端 token 保存到数据库并在以后重新使用它有多可靠? 我总是有一个用户对应一个 $custome
我是新手,正在尝试编写一个简单的登录应用程序。当我离开登录页面一段时间并输入用户名和密码时,它不会登录,而是会执行 session 过期行为。我检查了日志,发现每当我收到 INFO - Session
我想导航到刷新 token 过期时的登录 View 。我如何在Android中使用 OkHttp 处理这种情况。刷新 token 到期时,服务器以错误代码 403禁止的响应。有什么方法可以处理刷新 t
我想知道 Backbone 模型/ Controller 是否有一种标准方法来处理 session 结束。我正在使用 node.js 作为我的 webapp 的后端,现在我将 session 存储在内
我正在使用 https://www.paypal.com/cgi-bin/webscr 用于进行 PayPal 付款。当任何用户点击 PayNow 按钮时,它将导航到用户输入其凭据的 PayPal 页
我们最近注册了一个 iOS Enterprise 帐户用于内部应用分发。 搜索论坛发现两件事我想得到确认: 1- 企业分发证书有效期为 3 年。这是否意味着我们需要在此时使用新证书重新构建应用程序,否
我遇到了一个奇怪的场景。基本上在我正在做的每个网页上 session_start(); if(!isset($_SESSION['login'])) header("Location: log
有许多工具可用于监控通过 HTTPS 提供的服务的 SSL 过期,例如我们使用 https://github.com/prometheus/blackbox_exporter当 SSL 证书在内部和外
我正在使用 Vapor 4 开发一个 Web 应用程序。在请求之间一次将客户端制作的数据保存在服务器端几分钟会很有用。我想使用 session 来做到这一点。但是,我对如何在设定时间后自动销毁这些数据
我正在使用带有自定义身份验证的 firebase 9.x。根据文档, token 到期时间不能超过一小时。是否有一个我可以注册的监听器,当 token 过期时将调用它。 该文档还讨论了 token 的
正在关注 http://code.google.com/apis/gmail/oauth/protocol.html#imap我正在尝试为使用 OAuth 的 Gmail 实现 IMAP 客户端。 我
试图确定是否由对 Accounts.sendResetPasswordEmail() 的调用生成的 token 将永远过期。我在 accounts-password 上找不到任何进一步的文档。包超出了
编辑:我对这本书的当前状态不感兴趣。这是各种结账的历史记录。 实际上,整个问题可能格式错误,无法回答。但无论如何我得到了答案,这很好。我主要是在寻找WHEN -> THEN结构。 我有books可以检
根据我的理解,在使用 Drive Java API 时,建议构建一个 Drive 类的实例,然后存储它,以便其他线程可以共享它。如果持有对 Drive 实例的引用的进程是一个长时间运行的进程(即无限期
我读到的关于 cookie 的所有内容都说,将 cookie 的到期时间设置为零应该使其成为“ session ”cookie,浏览器将在退出时将其删除。 http://www.cookiecentr
我正在制作一个使用jwt来验证数据库调用的 Angular 应用程序。 就是当 token 在服务器上过期时,由于过期的 token 仍在本地存储中,因此应用程序开始提供空白页而不是数据。经过一些研究
我在grails应用程序中使用spring安全性。在其他浏览器上使用相同的用户名登录时,我需要使上一个 session 到期。并发 session 限制是否有帮助?这该怎么做? 最佳答案 I need
当我向手机发送推送通知时遇到了麻烦,它返回了以下错误: [X-SubscriptionStatus] => Expired [X-NotificationStatus] => Dropped [X-D
我需要创建一个用户登录/注销/ session 到期跟踪页面(ASP.Net)..很明显,当用户登录和注销时,我可以调用我的跟踪页面。如何检测 session 过期? 最佳答案 在有状态应用程序中,最
我是一名优秀的程序员,十分优秀!