1. 21 Sep, 2021 1 commit
    • Yedidya Feldblum's avatar
      let coarse clocks use underlying clock durations · 2157eecd
      Yedidya Feldblum authored
      Summary: Rather than having coarser `duration` types, the only purpose of which is signalling coarseness via a hijacked channel.
      
      Reviewed By: simpkins
      
      Differential Revision: D29221055
      
      fbshipit-source-id: 025a8b94972ee77a7d4a5bd34f269c492aaf2c4e
      2157eecd
  2. 20 Sep, 2021 2 commits
  3. 19 Sep, 2021 6 commits
    • Andrew Smith's avatar
      FanoutChannel: Change falcon code to use FanoutChannel's custom context · 40bf7f0e
      Andrew Smith authored
      Summary: This diff changes the users of FanoutChannel to use the context functionality added in the previous diff. It includes a new helper class in falcon/proxy called ProxyNotificationFanoutChannel, which handles updating the current version and sending an initial NewSubscription to new subscribers with that version. This diff then changes ProxyCache, ProxyProdEntity, OverriddenBlobEntity, and OverriddenMapEntity to use ProxyNotificationFanoutChannel. (Previously, the logic in ProxyNotificationFanoutChannel was duplicated in all 4 of those classes.)
      
      Reviewed By: aary
      
      Differential Revision: D30889895
      
      fbshipit-source-id: 39c9167f2bc6cc51e0b089eb5382faa498ffcb89
      40bf7f0e
    • Andrew Smith's avatar
      FanoutChannel: Add support for custom context · af581bd8
      Andrew Smith authored
      Summary:
      One common pattern with FanoutChannel is to send to new subscribers an initial update indicating the current state of the stream. This is currently the pattern for all uses of FanoutChannel.
      
      This pattern is currently accomplished by adding a transform to the input receiver before passing it to fanout channel. The transform updates the current state of the stream in some shared state object. That shared state object is then captured and used in the getInitialValues function passed to subscribe, in order to let new subscribers know the current state of the stream.
      
      However, this approach can lead to a race condition. In this approach, the transform function is executed (on the transform executor) before the getInitialValues function is executed (on the FanoutChannel executor). If someone adds a new subscriber in between, getInitialValues will use the updated shared state, even though the corresponding update has not yet been sent from the output of the transform to the input of the fanout channel.
      
      To solve this race condition, we need to ensure that new subscribers are not added between the shared state change and the fanning out of the update that led to the shared state change. To do this, this diff adds explicit support for a custom context object that can store state. The context object's update function is called on every update, allowing the shared state to be updated on each new value. The context object is also accessible to the getInitialValues function, which allows sending an update with the current state (based on the context) to new subscribers.
      
      This enables the desired pattern without a race condition, and avoids the need for a transform.
      
      Reviewed By: aary
      
      Differential Revision: D30889893
      
      fbshipit-source-id: 9a79fd5a823db1ae477b6b63170978925b791dda
      af581bd8
    • Andrew Smith's avatar
      FanoutChannel: Rename getNewReceiver/anyReceivers to subscribe/anySubscribers · c7e095e7
      Andrew Smith authored
      Summary: This diff renames getNewReceiver/anyReceivers to subscribe/anySubscribers.
      
      Reviewed By: aary
      
      Differential Revision: D30889890
      
      fbshipit-source-id: 8c3d8b1b1e930a703b5ce40e05ee129531af255e
      c7e095e7
    • Andrew Smith's avatar
      FanoutChannel: Change implementation to use FanoutSender · 702374dc
      Andrew Smith authored
      Summary:
      FanoutSender is like FanoutChannel, except that instead of listening to and fanning out values from an input receiver, it allows values to be directly pushed into the sender.
      
      This diff changes FanoutChannel to use FanoutSender, increasing code re-use. FanoutChannel now listens to values from the input receiver, and pushes them into a FanoutSender.
      
      Reviewed By: aary
      
      Differential Revision: D30889891
      
      fbshipit-source-id: 6d2ae416a5a0a895a1b1269d21f6830d45d92184
      702374dc
    • Andrew Smith's avatar
      FanoutChannel: Change TValue to ValueType · bf1b6d05
      Andrew Smith authored
      Summary: This diff changes TValue to ValueType in FanoutChannel (adhering to the folly guideline of not prefixing template parameters with T).
      
      Reviewed By: aary
      
      Differential Revision: D30889892
      
      fbshipit-source-id: 2ef79620289d554c9802124426d3c4ac70a06f12
      bf1b6d05
    • Kino Li's avatar
      Revert D31006847: Add RequestContext::try_get() · 140e8ccd
      Kino Li authored
      Differential Revision:
      D31006847 (https://github.com/facebook/folly/commit/865e847605911ed0eab96a0170fc372d09c3de5c)
      
      Original commit changeset: 2ce67a097c07
      
      fbshipit-source-id: 1bd09fcd6233f8c88969856c47317fbe8c197754
      140e8ccd
  4. 18 Sep, 2021 3 commits
    • Amlan Nayak's avatar
      Add RequestContext::try_get() · 865e8476
      Amlan Nayak authored
      Summary:
      Returns the `RequestContext` object if it already exists. Uses
      `SingletonThreadLocal::try_get()` underneath.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D31006847
      
      fbshipit-source-id: 2ce67a097c07de10b4359e3e70b820b80d885117
      865e8476
    • Alan Frindell's avatar
      Make all versions size_t · d5fb1013
      Alan Frindell authored
      Summary: as in title
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30966043
      
      fbshipit-source-id: aebe6972edfab79d610d01edcb737bd6102aa364
      d5fb1013
    • Yedidya Feldblum's avatar
      fix SingletonThreadLocal::try_get · 62887e3e
      Yedidya Feldblum authored
      Summary: Fixes an improper cast. `SingletonThreadLocal` allows a factory which returns any type, as long as that type can be reference-cast to the target type. So the new code must do a reference-cast.
      
      Reviewed By: amlannayak
      
      Differential Revision: D31022770
      
      fbshipit-source-id: 0fce6008fc3e21b6082ec7dcf3c3f9019b541ae9
      62887e3e
  5. 17 Sep, 2021 3 commits
    • Dmytro Stechenko's avatar
      Add OpenSSL Hmac copy ctor/op= · e698dfa1
      Dmytro Stechenko authored
      Summary:
      We already have this functionality for Digest part.
      Let's add it for Hmac.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30879080
      
      fbshipit-source-id: de6feb7aa5f6fa41f9595f00c8fa4cf3087719af
      e698dfa1
    • Yedidya Feldblum's avatar
      SingletonThreadLocal::try_get() · ba2db8d9
      Yedidya Feldblum authored
      Summary: Accesses the per-thread singleton if it has already been created.
      
      Reviewed By: amlannayak
      
      Differential Revision: D31003518
      
      fbshipit-source-id: 959418c4bc81da2b0ab7c639cdddb6d0beaf0121
      ba2db8d9
    • Alan Frindell's avatar
      Prefer returning read data on cancel · 06e4b1aa
      Alan Frindell authored
      Summary:
      It's possible that AsyncTransport read completed successfully in one loop, then the read coro gets a cancellation request.  In this case, prefer to return successfully with the read data.
      
      Read cancellation need not be fatal, eg: an application may just want to interrupt a read and come back to it later.  In this case, the successfully read data could be lost.
      
      In particular, if an EOF was lost, the application might start another read, AsyncSocket::setReadCB can assert in invalidState(ReadCallback*) because the DestructorGuard count is 0.
      
      Reviewed By: yairgott
      
      Differential Revision: D30964504
      
      fbshipit-source-id: ea963e6572f2bb552899d3b1e6274bbd0bcdc265
      06e4b1aa
  6. 16 Sep, 2021 4 commits
    • Cristian Lumezanu's avatar
      Add bytesAcked to TcpInfo · 366cd1ec
      Cristian Lumezanu authored
      Summary: Added the bytesAcked field in TcpInfo to represent the number of acknowledged bytes in the connection.
      
      Reviewed By: bschlinker
      
      Differential Revision: D30511022
      
      fbshipit-source-id: 6056c741399a058811fee0dbd94b1722c802db13
      366cd1ec
    • Erich Graham's avatar
      Ignore -Wcovered-switch-default Clang warning in Folly · 1456b13d
      Erich Graham authored
      Summary: These warnings appear when compiling with Clang modules. In this case, the `default` case should never be hit regardless of user input, so we may translate this to an unreachability hint.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30962081
      
      fbshipit-source-id: 48914f79a8d40f597cb60b8d8d6d9af37ac4b655
      1456b13d
    • Ilya Maykov's avatar
      make OpenSSLHash lazy-allocate the context, make move operations noexcept · 0ee04209
      Ilya Maykov authored
      Summary: See title.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30923907
      
      fbshipit-source-id: 8cbe749fa4662a171a247c8c16f6b9bc7b587e30
      0ee04209
    • Ilya Maykov's avatar
      fix self-assignment for OpenSSLHash::Digest, throw if context allocation... · 7b71f5e5
      Ilya Maykov authored
      fix self-assignment for OpenSSLHash::Digest, throw if context allocation fails, implement move support
      
      Summary:
      The copy assignment operator was not checking for self-assignment, which means the code was wrong when an object was being copied into itself.
      Also, allocation failure in the constructor would be silently ignored and result in a segfault crash later. Throw std::runtime_error if OpenSSL context allocation fails.
      Also, move constructor and move assignment operator were not implemented - they are now.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30879545
      
      fbshipit-source-id: 8b06f6fe97912a03ec5480a3b7c69aebf3a7f2ca
      7b71f5e5
  7. 15 Sep, 2021 1 commit
    • Rahul Arunapuram Gokul's avatar
      provide an API to easily redirect stdin/stdout/stderr to /dev/null · b258ee31
      Rahul Arunapuram Gokul authored
      Summary:
      It's somewhat common to want to ignore `stdout` / `stderr` when spawning a child, and the current mechanism we provide to do this is `folly::Subprocess::CLOSE`.
      
      However, this is somewhat dangerous when used without care, since any new files or sockets the child process opens will take on these low fds. From `man 2 open`,
      
      > The file descriptor returned by a successful call will be the lowest-numbered file descriptor not currently open for the process.
      
      Note that stdin/stdout/stderr are *not* special-cased here.
      
      To provide a safer way to not inherit or pipe the standard fds, provide a `folly::Subprocess::DEV_NULL` option instead, which hooks up the OS-relevant null device to the fd.
      
      `folly::Subprocess::CLOSE` will subsequently be removed.
      
      Reviewed By: yfeldblum, luciang
      
      Differential Revision: D30901400
      
      fbshipit-source-id: 0b59de5da6c6a0f714233c09788fa2d0020f3823
      b258ee31
  8. 14 Sep, 2021 6 commits
    • Filipe Brandenburger's avatar
      Detect and enable C++ couroutine support on CMake build with GCC · 4d5b7ad4
      Filipe Brandenburger authored
      Summary:
      This change updates the CMake config to detect whether GCC's `-fcoroutines` flag is supported and enable it for the build. This is required to enable support for Folly coroutines.
      
      Followed the instructions in GCC page about C++ coroutines to get them enabled.
      https://gcc.gnu.org/wiki/cxx-coroutines
      
      NOTE: This Wiki page used to indicate that exceptions had to be disabled to enable subroutines, but this only applied to experimental support for coroutines and it's no longer the case.
      
      This was uncovered by the fbthrift build, which needs Folly coroutines to implement streaming. A new fbthrift test using a stream type uncovered this missing feature in our build on Fedora.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30026779
      
      fbshipit-source-id: 3324c2fc52fe5db793bdaba9c81f41bfe6ef2242
      4d5b7ad4
    • Jolene Tan's avatar
      Deprecate folly::vformat · fb5c25d9
      Jolene Tan authored
      Reviewed By: vitaut
      
      Differential Revision: D30676171
      
      fbshipit-source-id: f820b1c08750c4d844925a82d5fd710bc8a1ca5c
      fb5c25d9
    • Maged Michael's avatar
      hazard pointers: Rearrange invoking asynchronous reclamation in executor · 94f01f8f
      Maged Michael authored
      Summary:
      Rearrange invoking asynchronous reclamation in executor.
      
      Eliminate the LOG message about skipping asynchronous reclamation.
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30908286
      
      fbshipit-source-id: ee79714bf8e6253a01d04c6d2ffa81895c4133c8
      94f01f8f
    • Pranjal Raihan's avatar
      Fix typo in macro: FOLLY_HAVE_SDT · 9258f5e9
      Pranjal Raihan authored
      Summary:
      `FOLLY_HAS_STD` and `FOLLY_HAVE_STD` are now `FOLLY_HAVE_SDT`.
      
      This typo reveals that the tests aren't run on platforms that don't have this feature enabled :/
      
      Reviewed By: yfeldblum
      
      Differential Revision: D30780817
      
      fbshipit-source-id: 338fdd5e5b08f3b5347609dd783f0a75506f9e30
      9258f5e9
    • Misha Shneerson's avatar
      print tid of the stalling thread. · 61e00b11
      Misha Shneerson authored
      Reviewed By: yfeldblum
      
      Differential Revision: D30914679
      
      fbshipit-source-id: 79a609ed1eda97a97e6eeeb47038a1e746b75e2d
      61e00b11
    • Huapeng Zhou's avatar
      folly: add freebind to async udp socket · a082c773
      Huapeng Zhou authored
      Summary:
      This is useful if we want to bind to a nonlocal address or an address that doesn't exist yet.
      
             IP_FREEBIND (since Linux 2.4)
                    If enabled, this boolean option allows binding to an IP
                    address that is nonlocal or does not (yet) exist.  This
                    permits listening on a socket, without requiring the
                    underlying network interface or the specified dynamic IP
                    address to be up at the time that the application is
                    trying to bind to it.  This option is the per-socket
                    equivalent of the ip_nonlocal_bind /proc interface
                    described below.
      
      Reviewed By: yfeldblum, mjoras
      
      Differential Revision: D30903919
      
      fbshipit-source-id: 09058cac1c14a4003525b0a7c5381ea301ca28da
      a082c773
  9. 11 Sep, 2021 1 commit
    • Srivatsan Ramesh's avatar
      Add co_schedule() method to AsyncScope · 83a6ce73
      Srivatsan Ramesh authored
      Summary: Adds a new method `co_schedule()` that takes a task, schedules it on the current executor and adds it to the AsyncScope.
      
      Reviewed By: andriigrynenko
      
      Differential Revision: D30005811
      
      fbshipit-source-id: 48c7aa240dc73c0b4dd54e539e620cf69c68c4fd
      83a6ce73
  10. 10 Sep, 2021 2 commits
  11. 09 Sep, 2021 5 commits
    • Aaryaman Sagar's avatar
      Handle std::vector<bool> in FanoutChannel · c0b40097
      Aaryaman Sagar authored
      Summary:
      std::vector<bool>::iterator::operator* returns a temporary proxy bool accessor
      in many implementations.  So range-based for loops over it don't work if we
      assume non-const lvalue-ref binding, eg.
      ```
      for (auto& ref : vectorBools) { ... }
      ```
      Won't compile.  Silly std::vector<bool>.
      
      Reviewed By: SmithAndr
      
      Differential Revision: D30833990
      
      fbshipit-source-id: cb8d53a48eb2a40587911ad2f0c50b99a472a59c
      c0b40097
    • Maged Michael's avatar
      hazard pointers: Shard the domain's list of untagged retired objects · 7d8dfb91
      Maged Michael authored
      Summary: Shard the domain's list of untagged retired objects.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D30806913
      
      fbshipit-source-id: 93061ebcd3f62c49eb0f96193e5961c4eeb6f061
      7d8dfb91
    • Maged Michael's avatar
      hazard pointers: Consolidate non-cohort and untagged cohort retired objects · 82f9889c
      Maged Michael authored
      Summary:
      Consolidate retired_, the list of non-cohort retired objects, with untagged_, the list of cohort untagged objects, in the domain.
      
      Eliminate redundant functions.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D30806882
      
      fbshipit-source-id: bdcbc4990a3d114f7f6bea294df498c5743bed43
      82f9889c
    • Maged Michael's avatar
      hazard pointers: Eliminate thread local lists of retired objects · b3833ef1
      Maged Michael authored
      Summary:
      Remove hazptr_priv, the thread-local list of retired objects.
      
      Non-cohort retired objects are pushed directly into the domain.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D30806863
      
      fbshipit-source-id: 526c90f5a198b4e42a55062cb7344e5286bf28fd
      b3833ef1
    • Adam Simpkins's avatar
      reflect the wangle github branch rename from master to main · 4f4c0ff8
      Adam Simpkins authored
      Summary:
      The primary branch in the GitHub wangle repository has been renamed from
      `master` to `main`.  Update the getdeps manifest to reflect this, so that
      getdeps builds correctly clone the repository.
      
      Reviewed By: xavierd
      
      Differential Revision: D30822418
      
      fbshipit-source-id: 9670fff1e85e77adf84485ff8f2236f8826630ef
      4f4c0ff8
  12. 08 Sep, 2021 5 commits
    • Lucian Grijincu's avatar
      fbcode: symbolizer: clang-12 DWARF5 emits Split DWARF inlining as... · eca99293
      Lucian Grijincu authored
      fbcode: symbolizer: clang-12 DWARF5 emits Split DWARF inlining as DW_TAG_skeleton_unit instead of DW_TAG_compile_unit
      
      Summary:
      ```name=clang-9
      $ llvm-dwarfdump --show-form buck-out/gen/aab7ed39/folly/experimental/symbolizer/test/symbolizer_test_utils_dwarf5_split_dwarf_inlining#compile-SymbolizerTestUtils.cpp.o1ef1b890\,platform009-clang/SymbolizerTestUtils.cpp.o
      .debug_info contents:
      0x00000000: Compile Unit: length = 0x00000127, format = DWARF32, version = 0x0005, unit_type = DW_UT_skeleton, abbr_offset = 0x0000, addr_size = 0x08, DWO_id = 0x7d3c88943756aebb (next unit at 0x0000012b)
      
      0x00000014: DW_TAG_compile_unit
                    DW_AT_stmt_list   (0x00000000)
                    DW_AT_str_offsets_base    (0x00000008)
                    DW_AT_comp_dir    (".")
                    DW_AT_GNU_pubnames        (true)
                    DW_AT_GNU_dwo_name        ("buck-out/dbg/gen/aab7ed39/folly/experimental/symbolizer/test/symbolizer_test_utils_dwarf5_split_dwarf_inlining#compile-SymbolizerTestUtils.cpp.o1ef1b890,platform009-clang/SymbolizerTestUtils.cpp.o")
                    DW_AT_low_pc      (0x0000000000000000)
                    DW_AT_ranges      (indexed (0x0) rangelist = 0x00000010
                       [0x0000000000000000, 0x000000000000005b)
                       [0x0000000000000000, 0x0000000000000065)
                       [0x0000000000000000, 0x000000000000005a)
                       [0x0000000000000000, 0x0000000000000065)
                       [0x0000000000000000, 0x000000000000000b)
                       [0x0000000000000000, 0x0000000000000076)
                       [0x0000000000000000, 0x0000000000000014)
                       [0x0000000000000000, 0x0000000000000065)
                       [0x0000000000000000, 0x0000000000000076)
                       [0x0000000000000000, 0x0000000000000014)
                       [0x0000000000000000, 0x0000000000000065)
                       [0x0000000000000000, 0x0000000000000085)
                       [0x0000000000000000, 0x000000000000000b))
                    DW_AT_addr_base   (0x00000008)
                    DW_AT_rnglists_base       (0x0000000c)
      
      ```
      ```name=clang-12
      $ llvm-dwarfdump --show-form buck-out/gen/aab7ed39/folly/experimental/symbolizer/test/symbolizer_test_utils_dwarf5_split_dwarf_inlining#compile-SymbolizerTestUtils.cpp.o1ef1b890\,platform009-clang-12/SymbolizerTestUtils.cpp.o
      .debug_info contents:
      0x00000000: Compile Unit: length = 0x00000127, format = DWARF32, version = 0x0005, unit_type = DW_UT_skeleton, abbr_offset = 0x0000, addr_size = 0x08, DWO_id = 0xb881aa098abf71b5 (next unit at 0x0000012b)
      
      0x00000014: DW_TAG_skeleton_unit
                    DW_AT_stmt_list [DW_FORM_sec_offset]	(0x00000000)
                    DW_AT_str_offsets_base [DW_FORM_sec_offset]	(0x00000008)
                    DW_AT_comp_dir [DW_FORM_strx1]	(".")
                    DW_AT_GNU_pubnames [DW_FORM_flag_present]	(true)
                    DW_AT_dwo_name [DW_FORM_strx1]	("buck-out/dbg/gen/aab7ed39/folly/experimental/symbolizer/test/symbolizer_test_utils_dwarf5_split_dwarf_inlining#compile-SymbolizerTestUtils.cpp.o1ef1b890,platform009-clang-12/SymbolizerTestUtils.cpp.o")
                    DW_AT_low_pc [DW_FORM_addr]	(0x0000000000000000)
                    DW_AT_ranges [DW_FORM_rnglistx]	(indexed (0x0) rangelist = 0x00000010
                       [0x0000000000000000, 0x000000000000004c)
                       [0x0000000000000000, 0x000000000000005f)
                       [0x0000000000000000, 0x0000000000000054)
                       [0x0000000000000000, 0x000000000000005f)
                       [0x0000000000000000, 0x000000000000000b)
                       [0x0000000000000000, 0x0000000000000070)
                       [0x0000000000000000, 0x0000000000000014)
                       [0x0000000000000000, 0x000000000000005f)
                       [0x0000000000000000, 0x0000000000000070)
                       [0x0000000000000000, 0x0000000000000014)
                       [0x0000000000000000, 0x000000000000005f)
                       [0x0000000000000000, 0x0000000000000086)
                       [0x0000000000000000, 0x000000000000000b))
                    DW_AT_addr_base [DW_FORM_sec_offset]	(0x00000008)
                    DW_AT_rnglists_base [DW_FORM_sec_offset]	(0x0000000c)
      ```
      
      Differential Revision: D30755400
      
      fbshipit-source-id: 6e7fd8bc9d3bef90a5195dc30dff60c489c4df35
      eca99293
    • Maged Michael's avatar
      SharedMutex: Add build-time flags for setting default spin and yield counts · 91b962e3
      Maged Michael authored
      Summary: Add build-time flags for setting default spin and yield counts.
      
      Reviewed By: fadimounir
      
      Differential Revision: D30761279
      
      fbshipit-source-id: 3b74bae438b1f87b1ca8b955bb244eb907b22891
      91b962e3
    • Nick Meyer's avatar
      Deprecate folly::svformat · 8ee373cf
      Nick Meyer authored
      Summary: Deprecate folly::svformat in favor of fmt::format
      
      Reviewed By: vitaut
      
      Differential Revision: D30521196
      
      fbshipit-source-id: 944054191bbfd296d1f666eb6ace6c4308f6d1ea
      8ee373cf
    • Maged Michael's avatar
      hazard pointers: Extend cleanup to cover cohort objects · 8ecee58a
      Maged Michael authored
      Summary:
      Extend cleanup to cover retired cohort objects.
      
      The change includes incrementing num_bulk_reclaims_ before invoking do_reclamation either directly or in an executor. The corresponding decrement is done at the completion of do_reclamation, which may happen on a different thread if reclamation is done in an executor.
      
      Reviewed By: davidtgoldblatt
      
      Differential Revision: D30513628
      
      fbshipit-source-id: 80227e85301274c66cc200ee5228654f1ca07d08
      8ecee58a
    • Adam Simpkins's avatar
      update the branch name for the fb303-source manifest · 58f83287
      Adam Simpkins authored
      Summary:
      The primary branch in the fb303 github repository was renamed from `master` to
      `main`.  Update the `fb303-source` manifest to reflect this.
      
      The main `fb303` manifest was already updated in D30700180 (https://github.com/facebook/folly/commit/60d9f5d791d7c6afb5f044538ae45fbe91a043e5).  The
      `fb303-source` manifest is a separate manifest that only fetches the fb303
      source code without building it.  This is only used by the `eden_scm`
      manifest.
      
      Reviewed By: fanzeyi
      
      Differential Revision: D30794650
      
      fbshipit-source-id: 0e7790f8ceb737ce2f26ab213e1f0f94c5b3f045
      58f83287
  13. 07 Sep, 2021 1 commit
    • Logan Evans's avatar
      Add a coinflip library. · d2643855
      Logan Evans authored
      Summary:
      The naive coinflip algorithm generates a random variable each time the function
      is called. We can avoid many of these calls to a random number generator by
      doing some tricky business with math stuff.
      
      See https://fb.workplace.com/groups/135724786501553/permalink/5767297086677600/
      for some discussion on the topic.
      
      The intention behind this code is that we will use it in HHVM. That's why it provides the static methods that allow the caller to supply their own storage space for the counter and their own random number generator.
      
      Reviewed By: bmaurer
      
      Differential Revision: D30440295
      
      fbshipit-source-id: ee0c3e49da3ec82a9fd6c8854b15ef107755ff39
      d2643855