Re: Idiomatic async programming like C# async/await

2014-09-14 Thread Kagamin via Digitalmars-d-learn

On Friday, 12 September 2014 at 03:59:58 UTC, Cliff wrote:
...but std.parallelism.Task requires parameterization on the 
function which the task would execute - that is clearly an 
implementation detail of the store.


I think, you can wrap the Task in a class.

abstract class CTask
{
  abstract void wait();
}

abstract class CTask(TResult)
{
  abstract TResult result();
}

class CTTask(TTask): CTask(TResult)
{
  TTask task; //std.parallelism.Task
  override void wait(){ ... }
  override TResult result(){ ... }
}


Re: Idiomatic async programming like C# async/await

2014-09-14 Thread Cliff via Digitalmars-d-learn

On Sunday, 14 September 2014 at 09:19:11 UTC, Kagamin wrote:

On Friday, 12 September 2014 at 03:59:58 UTC, Cliff wrote:
...but std.parallelism.Task requires parameterization on the 
function which the task would execute - that is clearly an 
implementation detail of the store.


I think, you can wrap the Task in a class.

abstract class CTask
{
  abstract void wait();
}

abstract class CTask(TResult)
{
  abstract TResult result();
}

class CTTask(TTask): CTask(TResult)
{
  TTask task; //std.parallelism.Task
  override void wait(){ ... }
  override TResult result(){ ... }
}


Yep, that's what I figured.  Thanks :)



Re: Idiomatic async programming like C# async/await

2014-09-13 Thread Kagamin via Digitalmars-d-learn
No, vibe provides synchronous non-blocking interface similar to 
async/await.


Re: Idiomatic async programming like C# async/await

2014-09-12 Thread Kagamin via Digitalmars-d-learn
async/await is not so much about futures/promises, but 
optimization of IO-bound operations, i.e. when you wait on 
network/disk, you don't consume stack, threads and similar 
resources, an analog in D is vibe.d


Re: Idiomatic async programming like C# async/await

2014-09-12 Thread Cliff via Digitalmars-d-learn

On Friday, 12 September 2014 at 07:15:33 UTC, Kagamin wrote:
async/await is not so much about futures/promises, but 
optimization of IO-bound operations, i.e. when you wait on 
network/disk, you don't consume stack, threads and similar 
resources, an analog in D is vibe.d


I should have been more clear - it's not the async/await bit I am
interested in so much as the Task behavior - that I have some
object which represents the (future) completed state of a task
without the recipient of that object having to know what the type
of the task function is as they are only interested in the task
result.

I'll take a closer look at vibe.d and see if they already have a
system representing this before I cook up my own.