Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET Port #30

Closed
antmdvs opened this issue Aug 15, 2016 · 2 comments
Closed

.NET Port #30

antmdvs opened this issue Aug 15, 2016 · 2 comments

Comments

@antmdvs
Copy link

antmdvs commented Aug 15, 2016

Same question as #26 but for .NET.

@leebyron
Copy link
Contributor

The key consideration is that you need a way to capture the calls to data loader during a single stack frame of execution.

There are two ways to do this:

  1. Your target environment has an event loop and you schedule the "dispatch" of a dataloader batch to occur after the current "tick" of the event loop.

  2. Your target environment has a stack of calls and you schedule the "dispatch" of a dataloader batch to occur when the current call stack has unwound.

This dataloader library for JavaScript actually uses approach 2) via the Promises "micro task queue" - which is a queue of operations to perform that begins empty at each call stack and is executed when the call stack unwinds. However if we had built this library before native Promises (or via using a Promise "polyfill") we use approach 1) where we enqueue work on the event loop (i.e. setTimeout).

Most, but not all, environments have an event loop - so the event loop approach is usually a good one. Nearly all environments have a call stack. If the native call stack does not support an "on unwind" task queue (likely) then a suitable substitute is to create a base function which you use everywhere a call stack could be created: in your program's main, in a custom version of Future so it can wrap completion callbacks, etc.

@leebyron leebyron mentioned this issue Aug 16, 2016
@leebyron
Copy link
Contributor

Closing this issue since questions were answered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants