0

I am parsing c++ codes using Libclang. I want to check for every function/method if it is asynchronous. For example:

void returnN(std::function<void(int)> handler){
    auto t = std::thread([handler](){
        handler(10);
    });
    t.join();
}

The above function is asynchronous since it is non-blocking. How can I detect the same using Libclang parsing in python?

I am parsing the entire code in a depth first search, and whenever I come across a FUNCTION_DECL cursor, I want to be able to print if it is asynchronous.

Jahnvi
  • 43
  • 1
  • 2
  • 6
    The `join` makes that function synchronous, it blocks until the lambda is done. – Mat Mar 13 '20 at 05:52
  • 2
    As the comment from @Mat shows even for humans it is hard to determine. You shouldn't expect an automated system to be much more reliable. – Klaus D. Mar 13 '20 at 05:57
  • @Mat Yes, my bad. I should have kept t.detach() instead of t.join() then? – Jahnvi Mar 13 '20 at 10:18
  • 1
    That would make it start a chunk of work asynchronously indeed. But the function itself from a C++ point of view is a plain ordinary function, there is no property/metadata that you could query telling you that it starts stuff in the background. – Mat Mar 13 '20 at 10:24

0 Answers0