{"id":1876,"date":"2018-04-24T00:16:34","date_gmt":"2018-04-23T15:16:34","guid":{"rendered":"http:\/\/research.itplants.com\/?p=1876"},"modified":"2018-04-24T07:08:08","modified_gmt":"2018-04-23T22:08:08","slug":"%e9%95%b7%e3%81%84%e6%99%82%e9%96%93%e3%81%aesetinterval%e3%81%ae%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/research.itplants.com\/?p=1876","title":{"rendered":"\u9577\u3044\u6642\u9593\u306esetInterval\u306e\u4ef6"},"content":{"rendered":"<p>\u3069\u3046\u3082\u3001Raspberry Pi\u3060\u3051\u306b\u8a72\u5f53\u3059\u308b\u3088\u3046\u306a\u30d0\u30b0\u306e\u3088\u3046\u3067\u3059\u3002setInterval\u3084setTimeout\u3001node-shcedule\u3067\u300130\u5206\u4ee5\u4e0a\u306e\u9577\u3044\u6642\u9593\u9593\u9694\u306b\u3059\u308b\u3068\u3001\u6307\u5b9a\u6642\u9593\u306b\u306a\u3063\u3066\u3082\u52d5\u4f5c\u3057\u306a\u3044\u300230\u5206\u4ee5\u4e0b\u306a\u3089\u3001\u6b63\u3057\u304f\u52d5\u4f5c\u3059\u308b\u3002\u3068\u3093\u3067\u3082\u306a\u3044\u30d0\u30b0\u3067\u3059\u3002\u89e3\u6c7a\u65b9\u6cd5\u306f\u300110\u5206\u9593\u9694\u3067\u3001\u30c0\u30df\u30fc\u306esetInterval\u3092\u5165\u308c\u308b\u3053\u3068\u3002\u89e3\u6c7a\u7b56\u304c\u5206\u304b\u308b\u307e\u3067\u3001\u6642\u9593\u304c\u304b\u304b\u3063\u3066\u3057\u307e\u3063\u305f\u3002<\/p>\n<p>MacOSX\u3067\u306f\u30011\u6642\u9593\u4ee5\u4e0a\u9577\u3044setInterval\u3067\u3082\u52d5\u4f5c\u3059\u308b\u306e\u3067\u3001Raspberry Pi \u56fa\u6709\u306e\u554f\u984c\u3060\u3068\u8a00\u3046\u3053\u3068\u306b\u306a\u304b\u306a\u304b\u6c17\u304c\u4ed8\u304b\u306a\u304b\u3063\u305f\u3002<\/p>\n<p>\u52d5\u4f5c\u3059\u308b\u4f8b<\/p>\n<p><code>setInterval(function(){ console.log((new Date())},10*60*1000);<\/code><\/p>\n<p>\u52d5\u4f5c\u3057\u306a\u3044\u4f8b<\/p>\n<p><code>setInterval(function(){ console.log((new Date())},60*60*1000);<\/code><\/p>\n<p>&nbsp;<\/p>\n<p>\u3053\u3046\u3059\u308c\u3070\u30011\u6642\u9593\u4ee5\u4e0a\u3067\u3082\u52d5\u4f5c\u3059\u308b\u3002<\/p>\n<p><code>setInterval(function(){ console.log((new Date())},10*60*1000);<br \/>\nsetInterval(function(){ console.log((new Date())},60*60*1000);<\/code><\/p>\n<p>10\u5206\u9593\u9694\u306e\u4f55\u3082\u3057\u306a\u3044\u3088\u3046\u306a\u30c0\u30df\u30fc\u30a4\u30f3\u30bf\u30fc\u30d0\u30eb\u3092\u5165\u308c\u308b\u3068\u4e0a\u624b\u304f\u52d5\u4f5c\u3059\u308b\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/nodejs\/node\/issues\/4262\">https:\/\/github.com\/nodejs\/node\/issues\/4262<\/a><\/p>\n<p>\u3053\u308c\u306f\u3001node\u306e\u30d0\u30b0\u304b\u3068\u601d\u3044\u307e\u3057\u305f\u304c\u3001Raspberry Pi\u306eOS\u304c32bit\u7248\u3060\u3068\u3044\u3046\u3053\u3068\u306b\u539f\u56e0\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/Samsung\/libtuv\/blob\/master\/src\/unix\/linux-core.c\">https:\/\/github.com\/Samsung\/libtuv\/blob\/master\/src\/unix\/linux-core.c<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>v<code>oid uv__io_poll(uv_loop_t* loop, int timeout) {<br \/>\n\/* A bug in kernels &lt; 2.6.37 makes timeouts larger than ~30 minutes<br \/>\n* effectively infinite on 32 bits architectures.  To avoid blocking<br \/>\n* indefinitely, we cap the timeout and poll again if necessary.<br \/>\n*<br \/>\n* Note that \"30 minutes\" is a simplification because it depends on<br \/>\n* the value of CONFIG_HZ.  The magic constant assumes CONFIG_HZ=1200,<br \/>\n* that being the largest value I have seen in the wild (and only once.)<br \/>\n*\/<br \/>\nstatic const int max_safe_timeout = 1789569;<br \/>\n\uff1a<br \/>\n\uff1a<br \/>\nfor (;;) {<br \/>\n\/* See the comment for max_safe_timeout for an explanation of why<br \/>\n* this is necessary.  Executive summary: kernel bug workaround.<br \/>\n*\/<br \/>\nif (sizeof(int32_t) == sizeof(long) &amp;&amp; timeout &gt;= max_safe_timeout)<br \/>\ntimeout = max_safe_timeout;<br \/>\n<\/code><br \/>\n<code>max_safe_timeout = 1789569;<\/code>\u306a\u306e\u3067\u300129.8\u5206\u3067\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3057\u307e\u3059\u3002<\/p>\n<p>Raspbian OS\u304c64bit\u7248\u306b\u306a\u308c\u3070\u3001\u6539\u5584\u3055\u308c\u308b\u3068\u601d\u308f\u308c\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3069\u3046\u3082\u3001Raspberry Pi\u3060\u3051\u306b\u8a72\u5f53\u3059\u308b\u3088\u3046\u306a\u30d0\u30b0\u306e\u3088\u3046\u3067\u3059\u3002setInterval\u3084setTimeout\u3001node-shcedule\u3067\u300130\u5206\u4ee5\u4e0a\u306e\u9577\u3044\u6642\u9593\u9593\u9694\u306b\u3059\u308b\u3068\u3001\u6307\u5b9a\u6642\u9593\u306b\u306a\u3063\u3066\u3082\u52d5\u4f5c\u3057\u306a\u3044\u300230\u5206\u4ee5\u4e0b\u306a&#8230;<\/p>\n<p><a class=\"more\" href=\"https:\/\/research.itplants.com\/?p=1876\"> Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/research.itplants.com\/index.php?rest_route=\/wp\/v2\/posts\/1876"}],"collection":[{"href":"https:\/\/research.itplants.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/research.itplants.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/research.itplants.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/research.itplants.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1876"}],"version-history":[{"count":4,"href":"https:\/\/research.itplants.com\/index.php?rest_route=\/wp\/v2\/posts\/1876\/revisions"}],"predecessor-version":[{"id":1880,"href":"https:\/\/research.itplants.com\/index.php?rest_route=\/wp\/v2\/posts\/1876\/revisions\/1880"}],"wp:attachment":[{"href":"https:\/\/research.itplants.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1876"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/research.itplants.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1876"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/research.itplants.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}