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
0
votes
1 answer

Sync call serial queue created in main is OK while sync call main queue in main is DEAD-LOCK

int main(void) { dispatch_queue_t queue = dispatch_queue_create(“com.somecompany.queue”, nil); dispatch_sync(queue, ^{ // task 1 NSLog(@"Situation 1"); }); return 0; } This is OK run in the…
0
votes
2 answers

app modifying the autolayout engine from a background thread

I am almost done migrating an iOS app of mine to Swift 3.0. But I still have a few cases similar to the one below. Most of them I have been able to solve by putting the problematic code on the main thread. In some other cases, I can't figure out,…
Michel
  • 10,303
  • 17
  • 82
  • 179
0
votes
0 answers

Labels of UITableViewCells loading very slowly

As part of syncing phone to server, the phone takes data from API to populate tableview. Local placeholder images appear immediately and are replaced with remote images asynchronously. The problem is that the label for each row does not appear for…
Arjun
  • 89
  • 1
  • 9
0
votes
1 answer

When does a process acquire the necessary resources?

I have been researching process scheduling as part of my studies. In doing so I have been referring to the following information: According to Abraham Silberschatz, Greg Gagne, and Peter Baer Galvin in; "Operating System Concepts, Ninth Edition ",…
Thomas Flood
  • 81
  • 1
  • 3
0
votes
3 answers

Two server requests completed before reloading the table view

I have these 2 requests that I want completed before reloading the table view(table view depends on both of them). I tried like below, but it does not work. Request 1 gets completed, then the table view reloads before everything being done in…
asheyla
  • 3,175
  • 5
  • 18
  • 34
0
votes
1 answer

GCD terminate request

I would like to send a request to server after a delay, but if user has changed state of UITextFiled this request should be terminated. What I have now is func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { …
JuicyFruit
  • 2,638
  • 2
  • 18
  • 35
0
votes
1 answer

Reloading row in table view is delayed inadvertently

When selecting a cell in the tableView I need to reload that row as well as setup some timers to fire AVAudioPlayers at certain dates (this setup takes a few seconds, the timers are starting to firing already, though, as intended). However,…
nontomatic
  • 2,003
  • 2
  • 24
  • 38
0
votes
1 answer

Reformatting function to swift 3.0 syntax

Please note that I did not create this function, it is a part of a library that has not been updated by it's creator. Could somebody please give advice as how to switch the function to swift 3.0? func debounce( delay:TimeInterval,…
Joshua Unrau
  • 313
  • 1
  • 2
  • 13
0
votes
3 answers

Best way to switch input source in Rust

I'm creating some ports based on arguments, but the ports don't live long enough to be passed to the next function, any lifetime-fu to be done? Better still, a way to adapt this to statically dispatch? fn init<'a>(matches: getopts::Matches) { …
414owen
  • 791
  • 3
  • 13
0
votes
1 answer

Dispatching actions in Redux best practices?

I have a large project I am working on at work and wondering about the proper way to dispatch actions. In my container for my component I map this function. const mapDispatchToProps = (dispatch) => { return { ackMessage:(convo)=> { …
0
votes
4 answers

Display letters one at a time with a delay

I am trying to display letters in a textView, one at a time, and with a delay but I am not able to get it right. I want it to look like someone is typing it out. Here is my current code: let delay = 2.0 * Double(NSEC_PER_SEC) let dispatchTime =…
user1079052
  • 3,803
  • 4
  • 30
  • 55
0
votes
2 answers

How to use GCD to draw image?

I drawn an image previously (on main thread, synchronously), it works well. Below is what I drawn: But now, I'd like to utilize GCD to redraw it for improving performance. But I got an image like below after I turn the code to use GCD: Why the…
Rex Tsao
  • 65
  • 1
  • 13
0
votes
1 answer

Objective C to Swift dispatch process

i'm having some trouble trying to convert the following code in Objective C to Swift: - (BOOL)loadEventsAtDate:(NSDate*)date { dispatch_async(self.bgQueue, ^{ [self bg_loadOneDay]; }); return YES; } - (void)bg_loadOneDay { …
eanton
  • 1
  • 1
0
votes
0 answers

Does C++ std::advance implementation, Need to judge the sign of "Distance" parameter?

I am recently learnign about some std::algorithm internals std::advance receives a number type "Distance", I suppose its internal implementation should look lie this: (tag-dispatch is suggested by [Effective C++]) template
Troskyvs
  • 7,537
  • 7
  • 47
  • 115
0
votes
1 answer

Swift protocol extension static-methods dispatch with superclass and subclass

I'm having a similar but slightly different problem described in: Swift protocol extension method dispatch with superclass and subclass. The problem is related to static methods on protocols. I have the following code: protocol Protocol: class { …