Search Results

Search found 3168 results on 127 pages for 'grand central dispatch'.

Page 6/127 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Dynamic Dispatch without Virtual Functions

    - by Kristopher Johnson
    I've got some legacy code that, instead of virtual functions, uses a kind field to do dynamic dispatch. It looks something like this: // Base struct shared by all subtypes // Plain-old data; can't use virtual functions struct POD { int kind; int GetFoo(); int GetBar(); int GetBaz(); int GetXyzzy(); }; enum Kind { Kind_Derived1, Kind_Derived2, Kind_Derived3 }; struct Derived1: POD { Derived1(): kind(Kind_Derived1) {} int GetFoo(); int GetBar(); int GetBaz(); int GetXyzzy(); // plus other type-specific data and function members }; struct Derived2: POD { Derived2(): kind(Kind_Derived2) {} int GetFoo(); int GetBar(); int GetBaz(); int GetXyzzy(); // plus other type-specific data and function members }; struct Derived3: POD { Derived3(): kind(Kind_Derived3) {} int GetFoo(); int GetBar(); int GetBaz(); int GetXyzzy(); // plus other type-specific data and function members }; and then the POD class's function members are implemented like this: int POD::GetFoo() { // Call kind-specific function switch (kind) { case Kind_Derived1: { Derived1 *pDerived1 = static_cast<Derived1*>(this); return pDerived1->GetFoo(); } case Kind_Derived2: { Derived2 *pDerived2 = static_cast<Derived2*>(this); return pDerived2->GetFoo(); } case Kind_Derived3: { Derived3 *pDerived3 = static_cast<Derived3*>(this); return pDerived3->GetFoo(); } default: throw UnknownKindException(kind, "GetFoo"); } } POD::GetBar(), POD::GetBaz(), POD::GetXyzzy(), and other members are implemented similarly. This example is simplified. The actual code has about a dozen different subtypes of POD, and a couple dozen methods. New subtypes of POD and new methods are added pretty frequently, and so every time we do that, we have to update all these switch statements. The typical way to handle this would be to declare the function members virtual in the POD class, but we can't do that because the objects reside in shared memory. There is a lot of code that depends on these structs being plain-old-data, so even if I could figure out some way to have virtual functions in shared-memory objects, I wouldn't want to do that. So, I'm looking for suggestions as to the best way to clean this up so that all the knowledge of how to call the subtype methods is centralized in one place, rather than scattered among a couple dozen switch statements in a couple dozen functions. What occurs to me is that I can create some sort of adapter class that wraps a POD and uses templates to minimize the redundancy. But before I start down that path, I'd like to know how others have dealt with this.

    Read the article

  • How to setup Mercurial central repository on shared hosting

    - by Metropolis
    Hey Everyone, I am trying to setup a central repository with shared hosting. I read all the way through this tutorial http://mercurial.selenic.com/wiki/PublishingRepositories to no avail. Here are the steps I took. 1. Copy hgwebdir.cgi file to directory at http://url.com/central_repository/hgwebdir.cgi 2. Added the following information to the hgweb.config file and copied it to same place. [paths] projectname = /home/username/central_repository/projectname [web] baseurl = /hg 3. Added the following to an htaccess file and copied it to the same place # Taken from http://www.pmwiki.org/wiki/Cookbook/CleanUrls#samedir # Used at http://ggap.sf.net/hg/ Options +ExecCGI RewriteEngine On #write base depending on where the base url lives RewriteBase /hg RewriteRule ^$ hgwebdir.cgi [L] # Send requests for files that exist to those files. RewriteCond %{REQUEST_FILENAME} !-f # Send requests for directories that exist to those directories. RewriteCond %{REQUEST_FILENAME} !-d # Send requests to hgwebdir.cgi, appending the rest of url. RewriteRule (.*) hgwebdir.cgi/$1 [QSA,L] 4. Uploaded the repository without the working directory to /home/user/central_repository/projectname 5. Tried to clone the repository to my computer using the folloing destination path: http://url.com/hg/projectname After going through these steps I get a 404: Not Found error. However if I change the destination path to http://url.com/central_repository/projectname It acts like it found the repository, It tells me it found the changesets, and it was adding the changesets and manifests, but then it says "transaction abort! HTTP Error 500: Internal Server Error. Thanks for any help! Metropolis

    Read the article

  • DVCS with a Windows central repository

    - by Mikko Rantanen
    We are currently using VSS for version control. Quite few of our developers are interested in a distributed model (And want to get rid of VSS). Our network is full of Windows machines and while our IT department has experience maintaining Linux machines they would prefer not to. What DVCS systems can host their central repository on Windows while providing.. Push access to the repository. Basic authentication. Mostly just a way to allow or deny access to the whole repository. No need for fine grained access. Server process so users don't need write right to the repository reducing the risk of accidentally messing with it. On the client side a GUI such as Tortoise would be more or less a requirement (Sorry, Windows shell sucks. :|). Ease of installation would be a huge plus as our IT department is already quite low on resources. And using windows credentials for authentication would be an advantage but not a requirement as long as the client is able to store the credentials. I have had a (really) quick look at Git, Mercurial and Bazaar. Git seemed to use ssh or simple WebDAV for repository access, requiring write permission for the users. Mercurial had a built in http server, but this seemed to be only for pull purposes. Update: Mercurial supports push as well. Bazaar Seemed to use sftp for repository access, again requiring a write permission for the users. Are there windows server processes for any DVCS systems and has anyone managed to set one up in a Windows land? And apologies if this is a duplicate question. I couldn't find one. Update Got Mercurial working for push purposes! Detailed list what was required can be found as an answer below.

    Read the article

  • How to maintain base files for development environment central while allowing people to change their

    - by Ittai
    Hi, what I'd like to do is have files in a central location so that when I add people to my development team they can see the base version of these files but meanwhile have the ability for the rest of the team to work with their own local version. I know I can just put the files in source-control (we use Tortoiese-SVN) and have my team change the local versions but I'd rather not as the exclamation mark signaling the file has been changed and needs to be committed, quite frankly, irritates me greatly. I'll give two examples of what I mean: We use quite a few build.xml files which relate to a single properties files which contains many definitions. Some of them can be different between team-members (mainly temporary working directories) and I'd like a new team-member to have the ability to get the properties file with the base config but change it if they wish. Have the eclipse settings file in the SVN so that when a new team-member joins they can just retrieve the files from the server and have a base system running. If they wish they will be able to change some of these settings. Thanks, Ittai

    Read the article

  • Thread scheduling Round Robin / scheduling dispatch

    - by MRP
    #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <semaphore.h> #define NUM_THREADS 4 #define COUNT_LIMIT 13 int done = 0; int count = 0; int quantum = 2; int thread_ids[4] = {0,1,2,3}; int thread_runtime[4] = {0,5,4,7}; pthread_mutex_t count_mutex; pthread_cond_t count_threshold_cv; void * inc_count(void * arg); static sem_t count_sem; int quit = 0; ///////// Inc_Count//////////////// void *inc_count(void *t) { long my_id = (long)t; int i; sem_wait(&count_sem); /////////////CRIT SECTION////////////////////////////////// printf("run_thread = %d\n",my_id); printf("%d \n",thread_runtime[my_id]); for( i=0; i < thread_runtime[my_id];i++) { printf("runtime= %d\n",thread_runtime[my_id]); pthread_mutex_lock(&count_mutex); count++; if (count == COUNT_LIMIT) { pthread_cond_signal(&count_threshold_cv); printf("inc_count(): thread %ld, count = %d Threshold reached.\n", my_id, count); } printf("inc_count(): thread %ld, count = %d, unlocking mutex\n",my_id, count); pthread_mutex_unlock(&count_mutex); sleep(1) ; }//End For sem_post(&count_sem); // Next Thread Enters Crit Section pthread_exit(NULL); } /////////// Count_Watch //////////////// void *watch_count(void *t) { long my_id = (long)t; printf("Starting watch_count(): thread %ld\n", my_id); pthread_mutex_lock(&count_mutex); if (count<COUNT_LIMIT) { pthread_cond_wait(&count_threshold_cv, &count_mutex); printf("watch_count(): thread %ld Condition signal received.\n", my_id); printf("watch_count(): thread %ld count now = %d.\n", my_id, count); } pthread_mutex_unlock(&count_mutex); pthread_exit(NULL); } ////////////////// Main //////////////// int main (int argc, char *argv[]) { int i; long t1=0, t2=1, t3=2, t4=3; pthread_t threads[4]; pthread_attr_t attr; sem_init(&count_sem, 0, 1); /* Initialize mutex and condition variable objects */ pthread_mutex_init(&count_mutex, NULL); pthread_cond_init (&count_threshold_cv, NULL); /* For portability, explicitly create threads in a joinable state */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); pthread_create(&threads[0], &attr, watch_count, (void *)t1); pthread_create(&threads[1], &attr, inc_count, (void *)t2); pthread_create(&threads[2], &attr, inc_count, (void *)t3); pthread_create(&threads[3], &attr, inc_count, (void *)t4); /* Wait for all threads to complete */ for (i=0; i<NUM_THREADS; i++) { pthread_join(threads[i], NULL); } printf ("Main(): Waited on %d threads. Done.\n", NUM_THREADS); /* Clean up and exit */ pthread_attr_destroy(&attr); pthread_mutex_destroy(&count_mutex); pthread_cond_destroy(&count_threshold_cv); pthread_exit(NULL); } I am trying to learn thread scheduling, there is a lot of technical coding that I don't know. I do know in theory how it should work, but having trouble getting started in code... I know, at least I think, this program is not real time and its not meant to be. Some how I need to create a scheduler dispatch to control the threads in the order they should run... RR FCFS SJF ect. Right now I don't have a dispatcher. What I do have is semaphores/ mutex to control the threads. This code does run FCFS... and I have been trying to use semaphores to create a RR.. but having a lot of trouble. I believe it would be easier to create a dispatcher but I dont know how. I need help, I am not looking for answers just direction.. some sample code will help to understand a bit more. Thank you.

    Read the article

  • Quelle firme représente le plus grand danger pour Google : Facebook ou Microsoft ? Eric Schmidt penche pour le second choix

    Quelle firme représente le plus grand danger pour Google : Facebook ou Microsoft ? Eric Schmidt penche pour le second choix Depuis quelques mois, les citations et rapports avançant que Facebook est le plus grand rival de Google ne cessent de se succéder. Mais est-ce vraiment le cas ? Pas au goût d'Eric Schmidt en tous cas, le CEO sortant de la firme de Mountain View. Selon lui, l'entreprise faisant le plus de concurrence à Google est Microsoft. Il précise que Redmond possède plus de cash, d'ingénieurs et de clients, ce qui pousse Google à "sentir la concurrence de Microsoft chaque jour". Alors que, parallèlement à cela, Facebook a clairement expliqué qu'il ne s'attaquerait pas ...

    Read the article

  • Now that Device Central is dead, how can I test my Flash Lite applications?

    - by Kirby
    I'm trying to use Flash Lite to make a simple game for my girlfriend, who only has a Nokia 5530, but I just realized in CS6 Adobe killed Device Central, so there's no way for me to test it without the device (and it's supposed to be a surprise). Is there any other way for me to test it? I know I can just export the movie and use Flash Player, but Device Central allowed me to test drag and drop and memory/processor usage for example... tl;dr, is there an alternative to Device Central for testing Flash Lite in older devices?

    Read the article

  • A question about Scala Objects

    - by Randin
    In the example for coding with Json using Databinder Dispatch Nathan uses an Object (Http) without a method, shown here: import dispatch._ import Http._ Http("http://www.fox.com/dollhouse/" >>> System.out ) How is he doing this?

    Read the article

  • Game/Application menu as a central part of the game/application

    - by Javalicious
    I am developing a Java application, well, it's actually a small game. I want to build up the application as follows: when it starts, a window should appear which has a menu with four choices: 'Start game', 'Options', 'Highscores' and 'Quit'. If you then click game, the game starts, preferrably in the same window, if you click options, well you know the drill. How should I program this? At the moment, I'm considering using a CardLayout, but I'm not sure this is the right way to do this. Do you guys maybe have another proposition?

    Read the article

  • How can I dispatch an PropertyChanged event from a subscription to an Interval based IObservable

    - by James Hay
    I'm getting an 'UnauthorizedAccesExpection - Invalid cross-thread access' exception when I try to raise a PropertyChanged event from within a subscription to an IObservable collection created through Observable.Interval(). With my limited threading knowledge I'm assuming that the interval is happening on some other thread while the event wants to happen on the UI thread??? An explanation of the problem would be very useful. The code looks a little like: var subscriber = Observable.Interval(TimeSpan.FromSeconds(1)) .Subscribe(x => { Prop = x; // setting property raises a PropertyChanged event }); Any solutions?

    Read the article

  • Java method overloading + double dispatch

    - by Max
    Can anybody explain in detail the reason the overloaded method print(Parent parent) is invoked when working with Child instance in my test piece of code? Any pecularities of virtual methods or methods overloading/resolution in Java involved here? Any direct reference to Java Lang Spec? Which term describes this behaviour? Thanks a lot. public class InheritancePlay { public static class Parent { public void doJob(Worker worker) { System.out.println("this is " + this.getClass().getName()); worker.print(this); } } public static class Child extends Parent { } public static class Worker { public void print(Parent parent) { System.out.println("Why this method resolution happens?"); } public void print(Child child) { System.out.println("This is not called"); } } public static void main(String[] args) { Child child = new Child(); Worker worker = new Worker(); child.doJob(worker); } }

    Read the article

  • How does the event dispatch thread work?

    - by Roman
    With the help of people on stackoverflow I was able to get the following working code of the simples GUI countdown (it just displays a window counting down seconds). My main problem with this code is the invokeLater stuff. As far as I understand the invokeLater send a task to the event dispatching thread (EDT) and then the EDT execute this task whenever it "can" (whatever it means). Is it right? To my understanding the code works like that: In the main method we use invokeLater to show the window (showGUI method). In other words, the code displaying the window will be executed in the EDT. In the main method we also start the counter and the counter (by construction) is executed in another thread (so it is not in the event dispatching thread). Right? The counter is executed in a separate thread and periodically it calls updateGUI. The updateGUI is supposed to update GUI. And GUI is working in the EDT. So, updateGUI should also be executed in the EDT. It is why the code for the updateGUI is inclosed in the invokeLater. Is it right? What is not clear to me is why we call the counter from the EDT. Anyway it is not executed in the EDT. It starts immediately a new thread and the counter is executed there. So, why we cannot call the counter in the main method after the invokeLater block? import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; public class CountdownNew { static JLabel label; // Method which defines the appearance of the window. public static void showGUI() { JFrame frame = new JFrame("Simple Countdown"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); label = new JLabel("Some Text"); frame.add(label); frame.pack(); frame.setVisible(true); } // Define a new thread in which the countdown is counting down. public static Thread counter = new Thread() { public void run() { for (int i=10; i>0; i=i-1) { updateGUI(i,label); try {Thread.sleep(1000);} catch(InterruptedException e) {}; } } }; // A method which updates GUI (sets a new value of JLabel). private static void updateGUI(final int i, final JLabel label) { SwingUtilities.invokeLater( new Runnable() { public void run() { label.setText("You have " + i + " seconds."); } } ); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { showGUI(); counter.start(); } }); } }

    Read the article

  • Make process run on non EDT (event dispatch thread) thread from EDT

    - by Aly
    I have a method running on the EDT and within that I want to make it execute something on a new (non EDT) thread. My current code is follows: @Override public void actionPerformed(ActionEvent arg0) { //gathering parameters from GUI //below code I want to run in new Thread and then kill this thread/(close the JFrame) new GameInitializer(userName, player, Constants.BLIND_STRUCTURE_FILES.get(blindStructure), handState); }

    Read the article

  • Recommended Python publish/subscribe/dispatch module ?

    - by Eli Bendersky
    From PyPubSub: Pypubsub provides a simple way for your Python application to decouple its components: parts of your application can publish messages (with or without data) and other parts can subscribe/receive them. This allows message "senders" and message "listeners" to be unaware of each other: one doesn't need to import the other a sender doesn't need to know "who" gets the messages, what the listeners will do with the data, or even if any listener will get the message data. similarly, listeners don't need to worry about where messages come from. This is a great tool for implementing a Model-View-Controller architecture or any similar architecture that promotes decoupling of its components. There seem to be quite a few Python modules for publishing/subscribing floating around the web, from PyPubSub, to PyDispatcher to simple "home-cooked" classes. Can you recommend a module that works well in most cases ? Which modules have you had positive experience with ? Negative ? Thanks in advance

    Read the article

  • Is There A Central Repository of Javascript Information?

    - by Brian
    For example, if you want information of PHP functions, you can go to http://www.php.net/ . If you want information of Perl functions you can to to http://www.cpan.org/ and/or use perldoc. If you want information on Java you can go to http://java.sun.com and/or use javadoc. However, if you want information on Javascript methods/functions and their attributes, return values, etc. where do you go? The reason I ask is I was playing with the "focus()" method and wondering if it could be passed any values or if it returned anything when called. I have done a cursory Google search but haven't found much. Does such a beast exist or am I out of luck? Thanks for reading, and have a good day.

    Read the article

  • How does the dispatch action call work in the Twitter sidebar

    - by phwd
    I would like to understand how the call for replies works as follows: <a href="http://twitter.com/replies" data="{"dispatch_action":"replies"}"> <span>@phwd</span> </a> This was taken from the homepage of Twitter. The section in particular being: data="{"dispatch_action":"replies"}" I believe (think), it is using Twitter's own twitter.js script and I do not want to interfere(or copy) with their code, I rather just want to know how the call works. My current setup is using Abraham's twitteroauth PHP library, jQuery and some Ajax to refresh the portion of the page needed using the following method : Use jQuery and PHP to build an Ajax-driven Web page [IBM link - I am a new user so I can only post one link] I apologize if this question is not formatted/worded well, it is my first time. Also I tried searching DocType and StackOverFlow. The Related Questions show me Struts but I am not sure it is that.

    Read the article

  • Jquery Validation Central Message Many Errors

    - by Iamjon
    Hi everyone, I have a form that is being valdated with the Jquery Validation Plugin. I have managed to get a centeral message "Please Recheck the form", and to have the input focus on the first error. To get this, I had to override the default message of each of the errors. I was wondering if anyone could help me figure out how I can have it display the error message associated with the first error input instead of a general error message. Here is the code: $("#Help-A-Noobie-Form" ).validate({ invalidHandler: function(form, validator) { $(this).find(":input.error:first").focus(); var message = 'Please Recheck The Form' ; $("#Help-A-Noobie-Form #Message p").addClass('red').html(message); }, showErrors: function(errorMap, errorList) { this.defaultShowErrors(); }, rules: { required:true, email: {email:true}, phone: {digits:true} }, messages: { email: "", phone: "", lastname: "", firstname: "", required:"" } })

    Read the article

  • drawbacks of storing all ''things' in a central table

    - by naiquevin
    Hi, I am not sure if there is a term to describe this, but I have observed that content management systems store all kinds of data in a single table with their bare minimum properties while the meta data is stored in another table in form of key value pairs. for eg. everything (blog posts, pages, images, events etc) is stored in one table and considered as a post. I understand that this allows for abstraction and easy extensibility we are considering designing our new project this way. It is not exactly a CMS but we plan to keep adding modules to it in stages. Lets say initially there will be only posts and images on which comments can be posted. Later on we might add videos which will also have the commenting feature. what are the drawbacks of this approach ? and will it work for a requirement like ours ? Thanks

    Read the article

  • How to dispatch a multimethod on the type of an array

    - by Arthur Ulfeldt
    I'm working on a multimethod that needs to update a hash for a bunch of different things in a sequence. Looked fairly straitforward until I tried to enter the 'type of an array of X'. (defmulti update-hash #(class %2)) (type (byte 1)) => java.lang.Byte (defmethod update-hash java.lang.Byte [md byte] (. md update byte)) (type (into-array [ (byte 1)])) => [Ljava.lang.Byte; (defmethod update-hash < WHAT GOES HERE > [md byte]

    Read the article

  • Android Convert Central Time to Local Time

    - by chedstone
    I have a MySql database that stores a timestamp for each record I insert. I pull that timestamp into my Android application as a string. My database is located on a server that has a TimeZone of CST. I want to convert that CST timestamp to the Android device's local time. Can someone help with this?

    Read the article

  • Peut-on vraiment lutter contre les botnets ? Le plus grand réseau de malwares démantelé recommence à

    Mise à jour du 12/03/10 Peut-on vraiment lutter contre les botnets ? Le plus grand réseau de malwares démantelé recommence à sévir en 48 heures La victoire de Microsoft contre le réseau Waldec pourrait n'être qu'une goutte d'eau dans l'océan (lire ci-avant). Certes, le dépôt d'une plainte avait effectivement permis d'utiliser des moyens légaux - une nouveauté à grande échelle - pour déconnecter un centre de commande du botnet Zeus et mettre hors service 277 n...

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >