PNG  IHDR  8] PLTE S =tRNS   PNG  IHDR  8] PLTE S =tRNS   REDROOM
PHP 7.4.33
Preview: timer Size: 5.74 KB
//opt/rh/gcc-toolset-14/root/usr/include/c++/14/experimental/timer

// <experimental/timer> -*- C++ -*-

// Copyright (C) 2015-2024 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file experimental/timer
 *  This is a TS C++ Library header.
 *  @ingroup networking-ts
 */

#ifndef _GLIBCXX_EXPERIMENTAL_TIMER
#define _GLIBCXX_EXPERIMENTAL_TIMER 1

#pragma GCC system_header

#include <bits/requires_hosted.h> // experimental is currently omitted

#if __cplusplus >= 201402L

#include <bits/chrono.h>
#include <system_error>
#include <thread>
#include <experimental/netfwd>
#include <experimental/io_context>
#include <experimental/bits/net.h>

namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
namespace experimental
{
namespace net
{
inline namespace v1
{

  /** @addtogroup networking-ts
   *  @{
   */

  template<typename _Clock>
    struct wait_traits
    {
      static typename _Clock::duration
      to_wait_duration(const typename _Clock::duration& __d)
      { return __d; }

      static typename _Clock::duration
      to_wait_duration(const typename _Clock::time_point& __t)
      {
	auto __now = _Clock::now();
	auto __diff = __t - __now;
	if (__diff > _Clock::duration::max())
	  return _Clock::duration::max();
	if (__diff < _Clock::duration::min())
	  return _Clock::duration::min();
	return __diff;
      }
    };

  template<typename _Clock, typename _WaitTraits>
    class basic_waitable_timer
    {
    public:
      // types:

      using executor_type = io_context::executor_type;
      using clock_type = _Clock;
      using duration = typename clock_type::duration;
      using time_point = typename clock_type::time_point;
      using traits_type = _WaitTraits;

      // construct / copy / destroy:

      explicit
      basic_waitable_timer(io_context& __ctx)
      : _M_ex(__ctx.get_executor()), _M_expiry()
      { }

      basic_waitable_timer(io_context& __ctx, const time_point& __t)
      : _M_ex(__ctx.get_executor()), _M_expiry(__t)
      { }

      basic_waitable_timer(io_context& __ctx, const duration& __d)
      : _M_ex(__ctx.get_executor()), _M_expiry(_Clock::now() + __d)
      { }

      basic_waitable_timer(const basic_waitable_timer&) = delete;

      basic_waitable_timer(basic_waitable_timer&& __rhs)
      : _M_ex(std::move(__rhs._M_ex)), _M_expiry(__rhs._M_expiry)
      {
	_M_key.swap(__rhs._M_key);
	__rhs._M_expiry = time_point{};
      }

      ~basic_waitable_timer() { cancel(); }

      basic_waitable_timer& operator=(const basic_waitable_timer&) = delete;

      basic_waitable_timer&
      operator=(basic_waitable_timer&& __rhs)
      {
	if (this == std::addressof(__rhs))
	  return *this;
	cancel();
	_M_ex = std::move(__rhs._M_ex);
	_M_expiry = __rhs._M_expiry;
	__rhs._M_expiry = time_point{};
	_M_key.swap(__rhs._M_key);
	return *this;
      }

      // basic_waitable_timer operations:

      executor_type get_executor() noexcept { return _M_ex; }

      size_t cancel() { return _M_ex.context().cancel(*this); }
      size_t cancel_one() { return _M_ex.context().cancel_one(*this); }

      time_point expiry() const { return _M_expiry; }

      size_t expires_at(const time_point& __t)
      {
	size_t __cancelled = cancel();
	_M_expiry = __t;
	return __cancelled;
      }

      size_t expires_after(const duration& __d)
      { return expires_at(_Clock::now() + __d); }

      void wait();
      void wait(error_code& __ec);

      template<typename _CompletionToken>
	__deduced_t<_CompletionToken, void(error_code)>
	async_wait(_CompletionToken&& __token)
	{
	  async_completion<_CompletionToken, void(error_code)> __init(__token);
	  _M_ex.context().async_wait(*this,
				     std::move(__init.completion_handler));
	  return __init.result.get();
	}

    private:
      executor_type _M_ex;
      time_point _M_expiry;

      struct _Key { };  // TODO move _M_expiry into here?
      unique_ptr<_Key> _M_key{new _Key};

      friend class io_context;
    };

  using system_timer = basic_waitable_timer<chrono::system_clock>;
  using steady_timer = basic_waitable_timer<chrono::steady_clock>;
  using high_resolution_timer
    = basic_waitable_timer<chrono::high_resolution_clock>;

  template<typename _Clock, typename _WaitTraits>
    void
    basic_waitable_timer<_Clock, _WaitTraits>::wait()
    {
      _M_ex.dispatch([this] {
	  while (clock_type::now() < _M_expiry)
	    this_thread::sleep_for(traits_type::to_wait_duration(_M_expiry));
      }, allocator<void>{});
    }

  template<typename _Clock, typename _WaitTraits>
    void
    basic_waitable_timer<_Clock, _WaitTraits>::wait(error_code&)
    {
      _M_ex.dispatch([this] {
	  while (clock_type::now() < _M_expiry)
	    this_thread::sleep_for(traits_type::to_wait_duration(_M_expiry));
      }, allocator<void>{});
    }

  /// @}

} // namespace v1
} // namespace net
} // namespace experimental
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std

#endif // C++14

#endif // _GLIBCXX_EXPERIMENTAL_TIMER

Directory Contents

Dirs: 1 × Files: 42

Name Size Perms Modified Actions
bits DIR
- drwxr-xr-x 2026-04-30 11:58:47
Edit Download
3.67 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
15.72 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
3.36 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
28.12 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.03 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.52 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.31 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
55.00 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
1.62 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.38 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
12.01 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
68.82 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
22.16 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
3.52 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.28 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.79 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
5.97 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
17.83 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
1.58 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
3.73 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
3.40 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
26.06 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
16.73 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.61 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.45 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.14 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
14.17 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.66 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.88 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
76.44 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.68 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.92 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
21.96 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
3.27 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.07 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
5.74 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.48 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
11.79 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
3.07 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.94 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
1.76 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download
2.37 KB lrw-r--r-- 2025-11-11 11:26:45
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).
 !"#$%&'(()*+,-./00123456789 t\ wIDATx ]ys  47Y ƒ -  "  Rv  < f{Ɛ $k l L > L  ~h^ 1  [  r G t& h  l F z3O Y ! p A(_g̷ E8 )S 8 c  Kb"z ~ 5 J xAL WU <  *  5 m;W a pB h ~P J 2 3 6 ҙ .Ƹ P i  4g F R L P ΪK/D  M v (a3 k J Œ4N5* SH ` SdJ z  O J Xՠ V>u ߱ BE&L b2 ?2` tX+  c CB A$ i b C ĀMB E : /  # Dx &l =q Ty  0 \p I ( L Ǎ { e 4k ;`u^ヲ eP!( d {  )T A 8 O;Ě n >;s6 !  :Nx `[S D HU ~ q›J F} a g*D 49 / pn k h (t 8NxƐF _!r չ7 ZR R׷ q/5") Ӎ NY 0 x sZ!   o  fu  ,  K"$ ? pg  㕣=  1» {h " fh7    y  } € +7  $ y " X —ą - G P u 4 m >J 5 L =V ' ^@I p ?MS xЌ XV P ! h "C NS9B8̢ ]!K  e   zA , ӏkbY  !< XQ ٿyS| *" f { w  4@[S <  # 0 ! js [m  =,~ o "ݎ DHf Wo $ g ! Vԅ t mB /y Wf V4񺍸 c+@x?  B ~u " xUN e 0 BĂ) ~J pz! 7y6]l Ԥ@ P a< O /DHC `≻  N m"$  0ObB }{ x AO FCG D R ^ "B  { WDH  UR l@ T #  +"d T ; 0 i  D}. 7 ` ' ] w rE &S i ƕiTD EL P _ u h $ Ա FG wVD G L R Zf ' .!] J /ZR oGЍs Mr Ĥ ʬ 3 Q [3 cL ` ^ p + ( F;# B 5 '  2Y f [  ϶R0e }  E 7 6M aۮ H <& n % L] E}Up x紉, Uw' Q  Ǯշo k ވۙ 0N94 VX5 xEDE l D #֤ } C o )W :  ^ s 9  bRf iX5u ཱི 4 :[  T 1. | [E 2ؽ Iy\ : o x K G 5 ylP ' uK E ftb/i[3 .g _  [3M n G, #NwQ5~  ؚ) | n =Ц"x qg gB ` 듘 ~ x w ? ? R~  _ u. &VQ K˻   H C ( TN˄+ `C dA nB׭ D 3"Z G ê ^k H_ /- ~ " R_  .8 Z_ 6@ o  xg  uP ? 3լ @7AM!  E7^ - =V L  x  g-D0  CtmW 7  O  G _ WD0 g C  w1 r d w : a | \  *" f nֳ ^ H# f L ` Z ۽hV  }S F r0Ù Bć5r] @! NL iQ]{s^=4 d  WD  "  "   M; t" 8 5 e dL| "-*st" ) SWD ?R[S e ooF  20.D ? bo =) A i o d ģ ZҰaO @E =) i D a &ܟa CϞ y6 ,<%{^x%{f8? `iw^ ?/ M * IEND B`