{
    "content": [
        {
            "type": "text",
            "text": "# POE::Resource::Clock (perldoc)\n\n## NAME\n\nPOE::Resource::Clock - internal clock used for ordering the queue\n\n## SYNOPSIS\n\nsub POE::Kernel::USEPOSIXRT { 0 }\nuse POE;\n\n## DESCRIPTION\n\nPOE::Resource::Clock is a helper module for POE::Kernel. It provides the features to keep an\ninternal monotonic clock and a wall clock. It also converts between this monotonic clock and the\nwall clock.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **EXPORTS** (6 subsections)\n- **SEE ALSO**\n- **BUGS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "POE::Resource::Clock",
        "section": "",
        "mode": "perldoc",
        "summary": "POE::Resource::Clock - internal clock used for ordering the queue",
        "synopsis": "sub POE::Kernel::USEPOSIXRT { 0 }\nuse POE;",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 69,
                "subsections": []
            },
            {
                "name": "EXPORTS",
                "lines": 3,
                "subsections": [
                    {
                        "name": "mono2wall",
                        "lines": 3
                    },
                    {
                        "name": "monotime",
                        "lines": 5
                    },
                    {
                        "name": "sleep",
                        "lines": 6
                    },
                    {
                        "name": "time",
                        "lines": 3
                    },
                    {
                        "name": "wall2mono",
                        "lines": 5
                    },
                    {
                        "name": "time",
                        "lines": 4
                    }
                ]
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "POE::Resource::Clock - internal clock used for ordering the queue\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "sub POE::Kernel::USEPOSIXRT { 0 }\nuse POE;\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "POE::Resource::Clock is a helper module for POE::Kernel. It provides the features to keep an\ninternal monotonic clock and a wall clock. It also converts between this monotonic clock and the\nwall clock.\n\nThe monotonic clock is used to keep an ordered queue of events. The wall clock is used to\ncommunicate the time with user code (\"alarmset\" in POE::Kernel, \"alarmremove\" in POE::Kernel).\n\nThere are 3 possible clock sources in order of preference: POSIX::RT::Clock, Time::HiRes and\n\"time\" in perlfunc. Only \"POSIX::RT::Clock\" has a separate monotonic and wall clock; the other\ntwo use the same source for both clocks.\n\nClock selection and behaviour is controlled with the following:\n\nUSEPOSIXRT\nexport POEUSEPOSIXRT=0\nor\nsub POE::Kernel::USEPOSIXRT { 0 }\n\nUses the \"monotonic\" clock source for queue priority and the \"realtime\" clock source for wall\nclock. Not used if POSIX::RT::Clock is not installed or your system does not have a \"monotonic\"\nclock.\n\nDefaults to true. If you want the old POE behaviour, set this to 0.\n\nUSESTATICEPOCH\nexport POEUSESTATICEPOCH=0\nor\nsub POE::Kernel::USESTATICEPOCH { 0 }\n\nThe epoch of the POSIX::RT::Clock monotonic is different from that of the realtime clock. For\ninstance on Linux 2.6.18, the monotonic clock is the number of seconds since system boot. This\nepoch is used to convert from walltime into monotonic time for \"alarm\" in POE::Kernel,\n\"alarmadd\" in POE::Kernel and \"alarmset\" in POE::Kernel. If \"USESTATICEPOCH\" is true (the\ndefault), then the epoch is calculated at load time. If false, the epoch is calculated each time\nit is needed.\n\nDefaults to true. Only relevant for if using POSIX::RT::Clock. Long-running POE servers should\nhave this set to false so that system clock skew does mess up the queue.\n\nIt is important to point out that without a static epoch, the ordering of the following two\nalarms is undefined.\n\n$poekernel->alarmset( a1 => $time );\n$poekernel->alarmset( a2 => $time );\n\nUSEEXACTEPOCH\nexport POEUSEEXACTEPOCH=1\nor\nsub POE::Kernel::USEEXACTEPOCH { 1 }\n\nThere currently no way to exactly get the monotonic clock's epoch. Instead the difference\nbetween the current monotonic clock value to the realtime clock's value is used. This is\nobviously inexact because there is a slight delay between the 2 system calls. Setting\nUSEEXACTEPOCH to true will calculate an average of this difference over 250 ms or at least 20\nsamples. What's more, the system calls are done in both orders (monotonic then realtime,\nrealtime then monotonic) to try and get a more exact value.\n\nDefaults to false. Only relevant if \"USESTATICEPOCH\" is true.\n\nUSEHIRES\nexport POEUSEHIRES=0\nor\nsub POE::Kernel::USEHIRES { 0 }\n\nUse Time::HiRes as both monotonic and wall clock source. This was POE's previous default clock.\n\nDefaults to true. Only relevant if \"USEPOSIXRT\" is false. Set this to false to use \"time\" in\nperlfunc.\n",
                "subsections": []
            },
            "EXPORTS": {
                "content": "This module optionally exports a few timekeeping helper functions.\n\nmono2wall",
                "subsections": [
                    {
                        "name": "mono2wall",
                        "content": "my $wall = mono2wall( $monotonic );\n\nmonotime"
                    },
                    {
                        "name": "monotime",
                        "content": "fall back to non-monotonic time if there are no monotonic clocks available.\n\nmy $monotonic = monotime();\n\nsleep"
                    },
                    {
                        "name": "sleep",
                        "content": "monotonic clock. This feature will degrade gracefully to non-monotonic high-resolution clocks,\nthen low-resolution clocks, depending on available libraries.\n\nsleep( 3.141 );\n\ntime"
                    },
                    {
                        "name": "time",
                        "content": "details.\n\nwall2mono"
                    },
                    {
                        "name": "wall2mono",
                        "content": "time. Its feature degrades gracefully depending on clock availability.\n\nmy $monotonic = wall2mono( $epoch );\n\nwalltime"
                    },
                    {
                        "name": "time",
                        "content": "resolution known.\n\nmy $epoch = walltime();\n"
                    }
                ]
            },
            "SEE ALSO": {
                "content": "See POE::Resource for general discussion about resources and the classes that manage them.\n",
                "subsections": []
            },
            "BUGS": {
                "content": "None known.\n\nAUTHORS & COPYRIGHTS\nPlease see POE for more information about authors and contributors.\n",
                "subsections": []
            }
        }
    }
}