Questions tagged [dispatch]

Dynamic dispatch (also known as dynamic binding) is the process of mapping a message to a specific sequence of code (method) at runtime. This is done to support the cases where the appropriate method cannot be determined at compile-time (i.e. statically).

Dynamic dispatch is only used for code invocation and not for other binding processes (such as for global variables) and the name is normally only used to describe a language feature where a runtime decision is required to determine which code to invoke.

This Object-Oriented feature allows substituting a particular implementation using the same interface, and therefore it enables polymorphism.

http://en.wikipedia.org/wiki/Dynamic_dispatch

974 questions
595
votes
30 answers

Using a dispatch_once singleton model in Swift

I'm trying to work out an appropriate singleton model for usage in Swift. So far, I've been able to get a non-thread safe model working as: class var sharedInstance: TPScopeManager { get { struct Static { static var instance:…
David Berry
  • 40,941
  • 12
  • 84
  • 95
78
votes
3 answers

Is there a way to store a function in a list or dictionary so that when the index (or key) is called it fires off the stored function?

For instance, I've tried things like this, which doesn't work: mydict = { 'funcList1': [foo(), bar(), goo()], 'funcList2': [foo(), goo(), bar()]} Is there some kind of structure with this kind of functionality? I realize that I could…
Zack
  • 4,177
  • 8
  • 34
  • 52
65
votes
12 answers

Get current dispatch queue?

I have a method which should support being called from any queue, and should expect to. It runs some code in a background thread itself, and then uses dispatch_get_main_queue when it returns a value to its block argument. I don't want it to force it…
Andrew
  • 15,935
  • 28
  • 121
  • 203
59
votes
4 answers

Difference between func() and (*this).func() in C++

I am working on someone else code in C++, and I found a weird call to a certain function func(). Here is an example: if(condition) func(); else (*this).func(); What is the difference between func() and (*this).func()? What are the cases…
gtatr
  • 6,947
  • 1
  • 17
  • 27
42
votes
4 answers

Android - Key Dispatching Timed Out

In my Android application I am getting a very strange crash, when I press a button (Image) on my UI the entire application freezes and after a couple of seconds I getthe dreaded force close dialog appearing. Here is what gets printed in the…
Donal Rafferty
  • 19,707
  • 39
  • 114
  • 191
41
votes
1 answer

R hangs when there are too many arguments in setMethod (or setGeneric)

Basically, when there are many arguments in setMethod or (setGeneric) it works very slowly. Here is a basic example: setClassUnion(name = "mNumeric", members = c("missing", "numeric")) setClass(Class = "classA", representation = representation(ID =…
HBat
  • 4,873
  • 4
  • 39
  • 56
37
votes
2 answers

What is dispatch used for in django?

I have been trying to wrap my head around the dispatch method, particularly in Django. However, I cannot seem to figure out exactly what it does. I tried to gain an understanding from the Django docs but didn't find them to informative on this…
Taylor Hardie
  • 375
  • 1
  • 3
  • 9
35
votes
3 answers

CLR implementation of virtual method calls to interface members

Out of curiosity: how does the CLR dispatch virtual method calls to interface members to the correct implementation? I know about the VTable that the CLR maintains for each type with method slots for each method, and the fact that for each interface…
Daniel A.A. Pelsmaeker
  • 47,471
  • 20
  • 111
  • 157
32
votes
2 answers

How to properly add and use D3 Events?

I'm having trouble understanding using D3 events and dispatch functions. I have a chart example that I've been working on called: "Vertical Bar Charts With Legends." Drawing the charts and the legends was easy enough but I'd like to add the ability…
Information Technology
  • 2,243
  • 3
  • 30
  • 46
29
votes
5 answers

React Redux dispatch action after another action

I have an async action, which fetch data from REST API: export const list = (top, skip) => dispatch => { dispatch({ type: 'LIST.REQUEST' }); $.get(API_URL, { top: top, skip: skip }) .done((data, testStatus, jqXHR) => { …
Denis Bednov
  • 357
  • 1
  • 4
  • 7
29
votes
7 answers

Apache proxfy_fcgi - Error dispatching request to

I have cloud hosting on Google, it sucks for to be honest but I am trying to get on with it, I installed LAMP stack on a VM and put my website in htdocs. When I try to access my site it gives me request timeout but sometimes it works for 5 minute…
require_once
  • 1,995
  • 3
  • 21
  • 29
27
votes
1 answer

DispatchSourceTimer and Swift 3.0

I can't figure out how to make dispatch timer work repeatedly in Swift 3.0. My code: let queue = DispatchQueue(label: "com.firm.app.timer", attributes: DispatchQueue.Attributes.concurrent) let timer =…
Derreck
  • 383
  • 1
  • 4
  • 10
24
votes
2 answers

Typescript: How to type the Dispatch in Redux

For example I want to remove the dispatch: any here: export const fetchAllAssets = () => (dispatch: any) => { dispatch(actionGetAllAssets); return fetchAll([getPrices(), getAvailableSupply()]).then((responses) => …
Leon Gaban
  • 36,509
  • 115
  • 332
  • 529
21
votes
5 answers

Stop dispatch_after

I use an animation for specify a tip to help the interaction with delay using these: let delay = 1.8 * Double(NSEC_PER_SEC) let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay)) dispatch_after(time, dispatch_get_main_queue()) { …
PlugInBoy
  • 979
  • 3
  • 13
  • 25
19
votes
2 answers

python3: singledispatch in class, how to dispatch self type

Using python3.4. Here I want use singledispatch to dispatch different type in __mul__ method . The code like this : class Vector(object): ## some code not paste @functools.singledispatch def __mul__(self, other): raise…
jiamo
  • 1,406
  • 1
  • 17
  • 29
1
2 3
64 65