Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-8707 Implement an async pure c++ HDFS client
  3. HDFS-9326

Create a generic function to synchronize async functions and methods.

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • None
    • HDFS-8707
    • hdfs-client
    • None

    Description

      The majority of the functionality in libhdfs++ is asynchronous, but some applications need synchronous operations. At the time of filing this only happens in 3 places in the C API, however that number is going to grow a lot once the C and high level C++ APIs expose all of the namenode functions.

      This synchronization is typically implemented like this:
      auto promise = std::make_shared<std::promise<T>>()
      std::future<T> = future(promise->get_future());

      auto async_callback = [promise] ()

      {promise->set_value(val);}

      ;

      SomeClass::AsyncMethod(async_callback);

      auto result = future.get()

      Ideally this could all be pushed into a templated function so that the promise and future don't need to be defined at the call site. This would probably take the form of doing a std::bind to get all the arguments in place at the call site and then passing that to the synchronize function.

      This appears to require some template magic that isn't always well supported; see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51979.

      Attachments

        Activity

          People

            James C James Clampffer
            James Clampffer James Clampffer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: