Listing Files using Multithreading with windows API in c++

后端 未结 2 328
借酒劲吻你
借酒劲吻你 2021-01-26 17:06

I have written a code that takes directory as input and outputs list of files in it.I implemented it in single thread.what to do in order to implement using multiple threads? pr

2条回答
  •  清酒与你
    2021-01-26 17:58

    global Queue ( consists of folders in a drive/directory ) Local Queue ( inside Thread function for Subfolders )

        while(true)
    {
        lock()
        if( Global q empty)
            unlock
            break
        else
           get first folder from global q
          put it in local q
         unlock
    
        while(local q not empty)
            take first folder from local q
            process it
            if( folder)
               put it in local q
            else
             put it in vector ( othr purpose)
    }
    

提交回复
热议问题