Questions tagged [deferred-execution]

219 questions
8
votes
1 answer

twisted: difference between `defer.execute` and `threads.deferToThread`

What is the difference between defer.execute() and threads.deferToThread() in twisted? Both take the same arguments - a function, and parameters to call it with - and return a deferred which will be fired with the result of calling the function.…
Claudiu
  • 224,032
  • 165
  • 485
  • 680
7
votes
4 answers

Does LINQ deferred execution occur when rendering the view, or earlier?

Given a very basic LINQ that is returned to a MVC view, at what exact point does the deferred execution fire? In the controller: public ActionResult Index() { var model = _fooService.GetAll(); return View(model); } In the model: @foreach…
JK.
  • 21,477
  • 35
  • 135
  • 214
6
votes
2 answers

Implementing the ‘defer’ statement from Go in Objective-C?

Today I read about the defer statement in the Go language: A defer statement pushes a function call onto a list. The list of saved calls is executed after the surrounding function returns. Defer is commonly used to simplify functions that…
zoul
  • 102,279
  • 44
  • 260
  • 354
6
votes
2 answers

How can i mock or test my deferred evaluation/execution functionality?

I have what could be seen as a bizarre hybrid of IQueryable and IList collections of domain objects passed up my application stack. I'm trying to maintain as much of the 'late querying' or 'lazy loading' as possible. I do this in two ways: By…
Matt Kocaj
  • 11,278
  • 6
  • 51
  • 79
6
votes
3 answers

How to defer a Django DB operation from within Twisted?

I have a normal Django site running. In addition, there is another twisted process, which listens for Jabber presence notifications and updates the Django DB using Django's ORM. So far it works as I just call the corresponding Django models (after…
blaf
6
votes
5 answers

Cache a Linq Query - is this possible?

So, this may seem like an edge case, but I'm simply wondering if this is possible. What I have is a combination of a static set and deferred set wrapped in an IEnumerable - for example: public IEnumerable MakeMyQuery() { // returns a…
Tejs
  • 40,736
  • 10
  • 68
  • 86
5
votes
1 answer

How can I iterate over several IEnumerables simultaneously

Assume I have two (or more) IEnumerable with many elements. Every IEnumerable has another type T. The lists can be extreme long and should not be loaded to memory completetly. IEnumerable ints = getManyInts(); IEnumerable strings =…
matthias.lukaszek
  • 2,200
  • 1
  • 23
  • 33
5
votes
2 answers

How does golang defer work in cycles?

I'm trying to handle reconnections to MongoDB. To do this I try to perform every operation three times (in case it fails with io.EOF) type MongoDB struct { session *mgo.Session DB *mgo.Database } func (d MongoDB)…
StTymur
  • 69
  • 1
  • 3
5
votes
1 answer

.NET Force method deferred execution

Consider the following scenario private static ConcurrentDictionary> CachedData; where multiple threads access this variable via a method calling ConcurrentDictionary dic =…
Miguel A. Arilla
  • 5,058
  • 1
  • 14
  • 27
5
votes
1 answer

C#, NUnit: How to deal with testing of exceptions and deferred execution

Say we have a method that looks like this: public IEnumerable GrowAll(this IEnumerable puppies) { if(subjects == null) throw new ArgumentNullException("subjects"); foreach(var puppy in puppies) yield return…
Svish
  • 152,914
  • 173
  • 462
  • 620
5
votes
1 answer

Python "deferred calculation" programming

This is a two part python question. The first part is about aesthetics and the second is about implementation. A sample of the code I've got working so far is attached at the bottom. The problem. I am trying to design a python module / class which…
Richard Green
  • 2,037
  • 2
  • 20
  • 38
5
votes
1 answer

Dart: Is using a zero duration timer the supported way of deferring work to the event loop

I discovered by experimenting that creating a timer with a duration of 0 allows me to defer work into the event queue. I really like this feature, because it allows avoiding a lot of nasty reentrancy issues. Is this intentional functionality that…
Jim Belton
  • 231
  • 2
  • 8
5
votes
1 answer

Does it make sense for an ASP.NET Web API method to return IQueryable?

I'm working on a project that uses the new Web API and I noticed somebody is returning an IQueryable from a Get method. My understanding is that IQueryable is useful for improving performance (deferred execution), but I don't think a client on…
Andy West
  • 12,302
  • 4
  • 34
  • 52
4
votes
1 answer

LINQ: using IEnumerable.Count() or IList.Count for better performance

Based on the following code: var grouped = filters.GroupBy(p => p.PropertyName); int numOfRowElements = grouped.Count(); foreach (IGrouping filter in grouped) { …
Klaus Nji
  • 18,107
  • 29
  • 105
  • 185
4
votes
1 answer

How do you create a python list comprehension of lambdas?

I am trying create a list of lambdas for deferred execution using a list comprehension. The below is a simple example. def func_a(message: str) -> None: print('a: ' + message) def func_b(message: str) -> None: print('b: ' +…
OldSchool
  • 459
  • 1
  • 3
  • 14
1 2
3
14 15