www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.paralellism.Task value type problems

reply Benjamin Thaut <code benjamin-thaut.de> writes:
I would like to use std.paralellism.TaskPool to schedule various 
tasks I create. The problem however is that these tasks don't 
have a lifetime which is bound to any function scope I have. So I 
need to create a new task object on the heap and push it into a 
array for bookkeeping. The problem however is that 
std.paralellism.Task is a struct and the only way to instanciate 
it is to use std.paralelism.task which returns it as a value. I 
have no idea at the moment how to allocate a instance of 
std.paralellism.Task on the heap. Any suggestions?

Kind Regards
Benjamin Thaut
Oct 19 2016
parent Ryan <ryan a_fake_email.non> writes:
On Wednesday, 19 October 2016 at 15:28:25 UTC, Benjamin Thaut 
wrote:
 I would like to use std.paralellism.TaskPool to schedule 
 various tasks I create. The problem however is that these tasks 
 don't have a lifetime which is bound to any function scope I 
 have. So I need to create a new task object on the heap and 
 push it into a array for bookkeeping. The problem however is 
 that std.paralellism.Task is a struct and the only way to 
 instanciate it is to use std.paralelism.task which returns it 
 as a value. I have no idea at the moment how to allocate a 
 instance of std.paralellism.Task on the heap. Any suggestions?

 Kind Regards
 Benjamin Thaut
Try the link below for the documentation. There are 2 versions of task, one returns a struct on the stack, the second returns a struct on the GC heap. https://dlang.org/phobos/std_parallelism.html#.task
Oct 19 2016