How would I implement a SlotQueue in java?

I am currently writing a MUD server in Java and I use Jython scripting to make everything dynamic however there is one drawback with that.. exec() eval() and execfile() are very very expensive so I created a series of worker threads that run and stay in the Jython script and if I make any changes to any of the script it can reload them. On the event side it preforms pretty well and using a DelayQueue I was able handle 30,000 events/sec on a 2.5ghz intel celeron.
My problem has to do with the players.. Having one thread per player appears that it would be bad for performance as someday I may have hundreds. If I make one thread that handles all the IO and passes work into a queue read by the worker threads I run into a problem. There is a race condition where a user might attack someone and then go east, there is a chance two of the worker threads might get both requests at the same time and if the one to move the player easy executed fast the player would find himself in a room by himself trying to attack something that isn't there.
I need some way to guarantee that the commands players enter will be handled in the order that the player issued them.
My idea was sort of a slot queue. The requirements would be that each element (a player) could only enter one item in the queue at a time and could not enter another item until the worker threads were done answering that request.
The queue could be any type of queue and each player could have their own semaphore that inits to 1. When the io thread puts an object in there it acquire a permit on the player's semaphore and block if there was none. When the worker threads pull from the queue it could release a permit for that player's semaphore.
So my final question is.. in the long run should I fear any issues with this or will it even perform better concurrently than each user having its own thread which processes its own requests? Better yet, is there a better way to process commands from player in order without ruining all concurrency?

however I don't know what
the angle of the clock hand would be, hence the
question. If I knew that I wouldn't have asked it.Angles in radians go from 0 to 2*pi. The clock goes
from 0 to 60. Set up a ratio.Seems pretty simple to me. Cicle 360 degrees. clock 60 positions. Might it be that each tick of the clock is 6 degrees ? Exercise left to the reader.

Similar Messages

  • How would you implement equals ()

    For complex classes with many data members, my dilema is:
    1. equals should return true only if all fields of the two objects are
    equals.
    2. equals should return true if the key(s) of the two objets are equal.
    For instance, we have the Class Person, that contains dozens of
    data: ID, name, age, job, salary, children, more 1000 items.
    Person is like a record in a DB table. There can not be two persons
    with the same ID.
    In this case, how would you implement equals, and why?
    thanks

    What I'm trying to say is: what is equality foryou?
    Two objects are equal if all there contents areequals
    or is it enough
    to compare their keys?
    In the latter case, there can happen, by somereason,
    that we can end
    up with two objects with the same keys, but all the
    rest of
    the contents different.i think you meant to say that:
    In the latter case, there can happen, by somereason,
    that we can end
    up with two objects with different keys, but
    all the rest of the contents the same.and the answer is, and listen carefully, it totally
    depends on the application you are writing. there
    is no hard definition of equality where custom classes
    are concerned... that is the answer.If this question arises, you should revisit your design.
    If two entities have equal keys, they should be considered to be equal. Otherwise the attributes you call keys are in the fact normal attributes and no keys.

  • How would I implement a FOR loop in real time?

    I am using a cRIO and would like to have several processes running in parallel.  A main functin will have a loop in it which will count up and an certain time intervals pass data to a parallel process.  I am not sure how LV will check the current time value and determine if it is time to send the parallel process information (it will send the parallel process a command to start at time X and stop at time Y).  I see the code in C as:
    for (i; i <= 60; i++)
         if (i==30)
            Function(1); //send "1" to function to  start action, equivalent of setting a variable in LV and continuously reading that variable in the parallel function
         if(i==45)
            Function(0); //send "0" to function to stop condition
        delay(1second);
    I am confused about how to create a loop that has a predetermined (changeable) time period that allows me to compare the timer to set times (i.e. 30 and 45) and perform a function if they are equal.  I can handle that compare part but I am not sure how to implement the loop.  Any help would be greatly appreciated.

    Hi,
    Why don't you use "Elapsed time.vi" ? Compare it with the time you require. Also you can use register event function to let the other process know a certain condition has occurred.
    Gaurav k:smileyhappy:
    Gaurav k
    CLD Certified !!!!!
    Do not forget to Mark solution and to give Kudo if problem is solved.

  • How would i implement this kind of canvas?

    Can anyone provide examples for creating a canvas similar to this one:?
    http://mates.ms.mff.cuni.cz/oracle/doc/forms45/dg/img/image112.gif
    The problem is, i dont know how to show 2 tables on a canvas with a 1-to-many relationship.
    Message was edited by:
    Arlas

    Okay, it still doesnt work, heres what i did:
    1. Created 3 datablocks (each representing a separate table, linked by foreign keys) under 1 form.
    2. Created 1 stacked canvas based on 1 datablock using Layout Wizard.
    3. Rightclicked on the canvas and opened Layout Wizard again to add another stacked canvas to the existing canvas.
    4. Repeated for the last datablock.
    5. Now i have 3 frames in 1 canvas.
    So far so good, but when i click "next" in the runtime of the form, i would like the other two frames of data items to act accordingly because after all these datablocks are linked by foreign keys.
    This is the problem if you see what i mean. I have 1 stacked canvas with 3 frames generated automatically by the wizard when i told it to add a stacked canvas to the existing canvas, yet so far, each frame is independant.
    Any Ideas?
    Message was edited by:
    Arlas

  • How would you implement a "real" on key released event?

    Hello there.
    I'm looking into key bindings and I'm trying to implement a "keep doing as long as space is pressed" feature. Figuratively speaking the optimal solution would be:
    space key is pressed -> call something.start()
    space key is released -> call something.stop()
    The thing is, the space key can be held down for several seconds and that does not generate one clear pressed and one clear released event. Instead you get a whole series of pressed and released events during the whole time the key is being pressed down. Actually it's logical. Click on some input field on your screen and keep a key pressed, you will see what I mean. :)
    So if I try to use:
    getInputMap().put(KeyStroke.getKeyStroke("pressed SPACE"), "start");...and...
    getInputMap().put(KeyStroke.getKeyStroke("released SPACE"), "stop");I don't get what I want. Start and stop are being called like crazy.
    So now, what would be the best way to react only to the first pressed and the last released event? Discarding events that follow each other too fast doesn't seem like an elegant solution.
    Thanks
    Cap

    Instead of timers I chose the following IMHO simpler and more reliable solution:
    public class Button
         private boolean on;
         public Button()
              on = false;
              // React to the SPACE key.
              getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("pressed SPACE"), "do");
              getActionMap().put("do", this);
         /* The problem we have to deal with is that a key being held down for several seconds
          * actually fires a whole havoc of pressed and released events. On Windows it fires
          * only a havoc of pressed events and then one released event when the button is
          * finally released. To make the button work right at least on Windows we keep track
          * of the state of the button (on = pressed, off = released). As soon as the button
          * is pressed, it doesn't react to pressed events anymore, this way the pressed havoc
          * can be ignored. It still reacts to released events though, so when the key is
          * finally released, the button goes into the off state again. On Linux this will never
          * work, because not only the pressed havoc, but also the released havoc is fired. */
         public void actionPerformed(ActionEvent arg0)
              if (on)
                   // The button is on, let's turn it off.
                   getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("pressed SPACE"), "do");
                   getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released SPACE"), "none");
                   on = false;
                   // TRIGGER SOME ACTION HERE
                   dont();
              else
                   // The button is off, let's turn it on.
                   getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("pressed SPACE"), "none");
                   getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("released SPACE"), "do");
                   on = true;
                   // TRIGGER SOME ACTION HERE
                   do();
    }Things would be much easier, if it was possible to differentiate, if the Action was triggerd by a "pressed" or a "released" event. I don't see a way to get this information from the ActionEvent object. If someone knows a way, please do tell.
    Cap

  • How would you implement a page like this?

    Hello
    When you look at www.autoweek.nl you see a little down 6 tab pages (Alle Rubrieken - Autonieuws etc.)
    My question is about the way you could implement the contents of one tab page.
    Would the content be several html regions (one for every message), or would it be a report? Or even something else?
    I'm struggling with the number of items. When I choose a html region for every news item I have a fixed number of HTML regions, which is not flexible.
    A report gives me this flexibility but is not that easy to layout?
    See also: http://www.autoweek.nl/nieuwsindex.php
    Any suggestions appreciated!
    Regards Erik
    Edited by: Erik Trip - Darwin IT on Nov 5, 2010 9:04 AM

    I would say a region per Tab and inside the Tab it is a report.
    brgds,
    Peter
    Blog: http://www.oracle-and-apex.com
    ApexLib: http://apexlib.oracleapex.info
    BuilderPlugin: http://builderplugin.oracleapex.info
    Work: http://www.click-click.at

  • How would you implement browser-based video conferencing?

    A client wants to build a website wherein multiple users (say 10 at a time) would be able to log in and converse with each other with sound and video in a virtual meeting room, with one user in particular broadcasting at a respectably high resolution, say 640x480. First of all, is this even possible to put together? If so, then what's the best way?
    I'm quite baffled as to how to approach this

    Diospyros wrote:
    A client wants to build a website wherein multiple users (say 10 at a time) would be able to log in and converse with each other with sound and video in a virtual meeting room, with one user in particular broadcasting at a respectably high resolution, say 640x480. First of all, is this even possible to put together? If so, then what's the best way?
    I'm quite baffled as to how to approach this
    It could be done with Flash but playback performance could be a issue with that many streams.

  • How would you implement a domain in my situation?

    Are the users shared between site 3 and sites 1 and 2? You could do a totally separate domain at Site 3 if not.

    So I have three sites that I manage. I won't get into details as to why some things are the way they are, so I will just let you know what I have to work with.Site 1 and Site 2 are connected by VPN. Site 3 is not connected to these sites by VPN and can't be. I have full control of the Site 3's network firewall, switches, everything. Site 1 and 2 I have full access to everything, but not the firewalls or network switchs (its a contact thing).I have not chosen a domain service yet. I have thought about Windows Active Directory on an in-house system, lack of VPN worries me. I have thought of off site domain services like Univention as well, but I have never met anyone that has used it personally. Are there off site/hosted domain services that work as good as hosting in-house. The stability would be nice, but I have always done everything...
    This topic first appeared in the Spiceworks Community

  • How would I implement something similar to SSRS data driven subscriptions in CRM 2015 Online?

    Requirement: Generate Report and send specific pricing information to a list of contacts based on field value.
    I'm new to CRM, but am well versed in SSRS and I'm looking to understand:
    1. Is it possible to create something like a data driven subscription in CRM?
    Everything I've looked at is from years ago, and I'm just looking for some high level directions I can pursue in order to fulfill this requirement.
    Thanks!

    Did you notice the difference between your image and theirs. Their image has a coordinate grid. This coordinate grid can be used to determine size, location of pixels, etc...
    If you add a grid, when you process the image, find the grid, then find the coordinate markings, then find the pixels in relation to these coordinate marking creating an internal buffer of the image.
    ie: have 0=white 1=black 2=grid 3=coordinate marking and make an internall representation of your image
    011002300000
    001002201000
    011102300010
    323232232323
    222222222222
    001002310000
    000102200100
    010002301000
    Just an idea, but look into the coordinate grid it may be the key to why they can process their image.
    DeltaCoder

  • How would I rewrite SELECT NEXT_DAY(SYSDATE, 'Sunday') NEXT_SUNDAY FROM DUAL in Java?

    Hi everyone,
    Being new to Java, I am finding that things I took for granted in SQL and PL/SQL are far from "second nature" here!
    Would someone tell me how would I rewrite the following in Java (for ADF)? My Google and OTN Community searches are coming up empty-handed. Any function in which I pass a date and get a date back for the next Sunday is fine, i.e., I don't need the SQL.
    select
    next_day(sysdate, 'Sunday') next_sunday
    from dual;
    Thanks in advance!
    James

        public void calculateNextDay()
            Calendar c=Calendar.getInstance();
            c.set(Calendar.DAY_OF_WEEK,Calendar.SUNDAY);
            c.set(Calendar.HOUR_OF_DAY,0);
            c.set(Calendar.MINUTE,0);
            c.set(Calendar.SECOND,0);
            DateFormat df=new SimpleDateFormat("EEE yyyy/MM/dd HH:mm:ss");
            //PRINT PAST SUNDAY
            System.out.println("past sunday  - " + df.format(c.getTime()));     
            c.add(Calendar.DATE,7);
            //PRINT NEXT SUNDAY
            System.out.println("next sunday  - " + df.format(c.getTime()));     
            c.add(Calendar.DATE,7);       

  • How do you access external .exe within Java?

    Say I wanted to feed a command to a .exe, right? How would go about doing that in Java and is there a cross-platform method or does it vary?

    helplessguyhelp wrote:
    tlgkumar,
    Hi can you help me to solve a problem??Dude, just start a new thread with your question, and whoever sees it and finds it worth their time will answer.

  • How do I implement aggregates on BPS?

    Hi everyone!
    Working with BW-BPS 3.5 I have the following question: Within an input layout I create planning data on a daily basis. In an output layout I then want to view my planning data aggregated on a monthly level.
    How would I implement this aggregation? Do I use the aggregate functionality of BW? Or do I use any BPS aggregation functionality (like FOX or something else)?
    Thanks in advance,  Daniel

    Hi Daniel,
    you need nothing special.
    Input Layout: Use planning level with time characteristic day
    Output Layout: Use planning level with time characteristic month
    In the planning area create a derivation day -> month. The the system does the aggregation for you.
    Regards,
    Gregor

  • Implementing Joda Time in Java Netbeans

    How do i implement joda time in java netbeans. i am reporting using ireports and on run time my report is showing java util and and time for a variable say DateOfBirth for which i don want the time to be include.how do i resolve it.
    Thank yu so much

    I am not sure I understand your question as it's posted. But let me offer a reference- there's a book being written by this guy:
    http://www.netbeans.org/community/articles/interviews/yarda-tulach.html
    on designing modular APIs. He's been involved in Netbeans from the start. Writing a plugin API is non-trivial where non-trivial means, essentially, non-commoditized knowledge needed to solve what's known as a "wicked problem".
    If you're asking what I think you're asking, no one is going to be able t type an answer to you in Sun's forums, but it's a good question and the right question to ask, that's for sure.
    best of luck!

  • Application Builder: How should I implement application updates?

    Hi!
    I am planning to distribute a LabVIEW application by creating an installer with application builder. Now I wonder if updates / uninstallations of previous versions can be implemented somehow.
    Or how would I implement updates? Should I just overwrite the previous files or should I do parallel installations into different folders?
    Any ideas are welcome.
    Regards,
    Anguel

    Anguel,
    i think this post should answer your question.
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • How to implement node affinity for java type concurrent programs.

    How to run a concurrent program against a specific RAC instance with PCP/RAC setup? (Doc ID 1129203.1)
    This works for non java registered concurrent programs but not java registered with use the DBC file
    EBS RAC environment with two RAC nodes. We would like to implement node affinity to allow concurrent programs to be directed to a single RAC instance. Oracle have provided the NODE AFFINITY ability via the concurrent program definition in Session Control. This then uses the entry in the 10.1.2 tnsnames.ora to pass the request directly through to the instance as defined by Node Affinity.
    However, concurrent programs defined as type java do not access the database by the 10.1.2 tnsnames.ora but use the dbc file under $FND_SECURE. This file is configured for both self service and concurrent processing so any change to the dbc file entry will affect both self service and concurrent processing.
    How to we implement a node affinity solution for concurrent programs without affecting Self Service conncetions? We'd like the dbc file to directly connect java concurrernt programs through to one instance but the self service connections to use the SERVICE name only.
    Regards.
    philippe.

    Did you think about Online/Batch node concept ? By that way you can seggrecate application connection.

Maybe you are looking for

  • Profti Center Determination for Non Leading Ledger

    Hi, We are on ECC6, EHP4. We have activated non leadgin ledger and I am facing issue in asset accounting transaction type for Write up,  I have created for Non leading ledger (IFRS) . Following is the issue. I have created the transaction type "Z71"

  • ESS is not working properly after upgrade from 4.7 to ECC6.0

    ESS Scenario in 4.7 4.7 Scenario: The IMG configuration u201CWork and Life Eventsu201D is done to map them with the PZM3 service (Home Page) to get them as different folders/links on the home page as given below: List of Services used to set up ESS:

  • Want to save file as a name of controls(Boolean Tick)

    Hello all,  I have many option on front panel like 1. Panel_One 2. Panel_Two 3.Panel_Three As user will select outof this that name should be given to file name. But its boolean so how to transfer the label of Boolean Tick as file name? It should als

  • Nokia E5 Calendar Sync Settings Help

    Hello, I'd like to sync my calendar on Ovi.com with teh one on my Nokia E5. I followed all these instructions here: 1. On your computer, go to www.ovi.com 2. Sign in your account 3. Click on the calendar tab 4. Click on "manage device" 5. Click on re

  • Imported images not showing in catalog

    I have imported images from my Canon 5D markIII and somewhere along the way, I've made an error in the settings.  The images are on my computer but not showing up in a folder in the LR4 catalog...how do I get them into the catalog?  When I try to fin