Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-27896

Develop compiletime or runtime guarantees for calls to single-thread context functions.

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 4.3.4
    • None
    • Internal Code
    • None
    • Fully Compatible
    • Service Arch 2020-02-10, Service Arch 2020-02-24, Service Arch 2020-03-09

    Description

      There are myriad functions that are only safe to call in single-threaded context, such as by Mongo initializer code.

      Two alternative designs here:

      1. stdx::thread uses a std::once initialization to transition a global boolean to false, indicating that the system is (potentially) no longer single threaded. Initialization and similar functions can assert on this global boolean (via an observer.)

      2. Create an object which is constructible only by `int main(...)`, and pass this object to initializer functions by const reference. When main is going to launch its first thread, call into a `multithread_main` function which does not take the `SingleThreaded` mode object (token) as an argument – thus making it buried (and lost forever) in main.

      The first design is simple to implement, but it is a runtime-check. The second design is a partial compile-time guarantee of threading concerns.

      Attachments

        Activity

          People

            amirsaman.memaripour@mongodb.com Amirsaman Memaripour
            adam.martin@mongodb.com ADAM Martin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: