locked
Concurrency task groups RRS feed

  • Question

  • I'm new to the Microsoft Concurrency Runtime (and asynchronous programming in general), and I'm trying to understand what can and can't be done with it. Is it possible to create a task group such that the tasks execute in the order in which they were added, and any task doesn't start until the previous one ends?

    I'm trying to understand if there's a more general and devolved way of dealing with tasks compared to chaining several tasks within a single member function. For example, let's say I have a program that creates resources at different points in the program, and the order in which the resources are created matters. Could any resource creation function that was called simply append a task to the end of a central task list, with the result that the tasks execute in the order in which they were added (i.e. the order in which the resource creation functions were called)?

    Thanks,

    RobertF

    Sunday, July 1, 2012 4:42 PM

All replies

  • How to: Implement Various Producer-Consumer Patterns


    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP

    Sunday, July 1, 2012 5:22 PM
  • Hi,

     

    For addition, you can try to use Scheduler Instances. Please follow these samples

     

    How to: Manage a Scheduler Instance

    http://msdn.microsoft.com/en-us/library/ee513829.aspx

    How to: Specify Specific Scheduler Policies

    http://msdn.microsoft.com/en-us/library/dd984038.aspx

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us


    Monday, July 2, 2012 7:29 AM
  • Thanks for the links, but since I'm trying to get an idea of the limitations of the task class, I think that may be taking me off-course a little bit. The tasks I had in mind don't need to communicate or share data.

    I may not have explained myself very well in my original post (also I referred to task groups when I should have restricted myself just to the task class). The scenario I have in mind requires tasks to be executed sequentially, but asynchronously to the main thread. I think it's something like this post is referring to: http://stackoverflow.com/questions/4134641/sequential-asynchronous-tasks-without-blocking.

    The scenario I had in mind relates to a DirectX application. If I create a Metro DirectX application using the Visual Studio template, one of the functions produced is CubeRenderer::CreateDeviceResources(). This function uses tasks to read in shader files, create the shaders, and it also creates vertex and index buffers.

    My question related to what would happen if these sort of resource allocations happened not in the same function but at separate places in the program, and there was also the requirement that for a given resource to be allocated, other resources had to be already in place. For example, the template generated DirectX program doesn't do this, but if, say, the DirectX main device creation were put in a task in DirectXBase::CreateDeviceResources(), the resources in CubeRenderer:CreateDeviceResources() couldn't be created until the device had been created.

    One way I started to think this could be done was if there was something like a global queue of tasks, which was accessible from anywhere in the program to which tasks could be appended such that the order of the task queue reflected the order in which the functions that allocated the tasks were called. I'm still trying to get my head round the syntax of how this might done, but I hope I've explained myself a bit better this time.

    Robert

    Monday, July 2, 2012 1:17 PM
  • There is an agents library in PPL if you want to control the tasks by data flow instead of control flow.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP

    Monday, July 2, 2012 3:31 PM
  • Moving thread to the Parrallel Computing in C++ and Native Code where the real experts live.

    Tuesday, July 3, 2012 9:00 PM