Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • King Bosnia: Any recommendations to private servers?
      October 18, 2018, 04:47:35 PM
    • FightMexoxo: oi i have the files if anyone whats em
      October 18, 2018, 12:44:42 AM
    • The Wanderer: Whoops
      October 15, 2018, 12:56:18 AM
    • The Wanderer: Making own operating system
      October 15, 2018, 12:56:11 AM
    • Travas: no
      October 07, 2018, 04:03:36 PM
    • Saltyspade10: Server still up and running?
      October 05, 2018, 07:13:41 PM
    • Wesam: Can someone upload moparscape.jar?
      October 05, 2018, 11:43:43 AM
    • Ligoe: yo
      September 30, 2018, 12:48:15 PM
    • Ligoe: how come i can't login the game
      September 30, 2018, 12:48:03 PM
    • fuzzout: Anybody here with experience in using Luna source? I'm looking to develop something, but can't seem to get any of my clients to work with it...
      September 26, 2018, 10:47:27 AM
    • `Discardedx2`: ?
      September 21, 2018, 12:24:09 PM
    • Pookey71: ARE YOU HERE TO RECEIVE MY LIMP PENIS!?
      September 20, 2018, 11:55:24 PM
    • Pookey71: THIS IS DEMOCRACY MANIFESTO
      September 20, 2018, 11:55:07 PM
    • Vasi28: Гранд
      September 03, 2018, 07:06:22 PM
    • Rash: test
      August 30, 2018, 09:09:18 PM
    • Guruu:[link]
      August 30, 2018, 12:04:45 AM
    • Guruu: am i allowed to post links shoutbox?
      August 30, 2018, 12:03:46 AM
    • drubrkletern:[link] feedback wanted
      August 28, 2018, 03:55:17 PM
    • bugz000: Anyone got a link for the old ass silab client and cache.zip? from mopar 3.2 era :) 317
      August 25, 2018, 12:48:15 AM
    • cholland2015: Does anyone know where I can download the old moparscape client/server?
      August 24, 2018, 02:30:51 PM

    Author Topic: soldout  (Read 575 times)

    0 Members and 1 Guest are viewing this topic.

    OfflineRandQm

    • Member
    • ****
    • Posts: 4,220
    • Thanks: +0/-0
      • View Profile
    soldout
    « on: September 15, 2014, 01:37:14 PM »
    soldout
    « Last Edit: September 15, 2016, 12:38:11 PM by RandQm »
    soldout

    contact me on [email protected] if you're looking for me
    Runescape Gambling

    Offlinetyb97

    • Member
    • ****
    • Posts: 6,195
    • Thanks: +0/-0
      • View Profile
    Re: Timed Event System - Requesting feedback
    « Reply #1 on: September 15, 2014, 01:42:01 PM »
    I'm not sure how efficient or safe creating a new thread for each event is. However, nice use of parallelism.
    what if i want to stick it in? you got a problem with that?
    Runescape Gambling

    OfflineRandQm

    • Member
    • ****
    • Posts: 4,220
    • Thanks: +0/-0
      • View Profile
    Re: Timed Event System - Requesting feedback
    « Reply #2 on: September 15, 2014, 01:49:41 PM »
    I'm not sure how efficient or safe creating a new thread for each event is. However, nice use of parallelism.
    I assume you mean creating a new thread for every parallel event as the normal ones run on the same thread?
    As you can see I'm catching the exception if there would be to many threads, but according to my research a simple computer can run
    over a K threads so I don't think that would be a problem very quick.
    soldout

    contact me on [email protected] if you're looking for me
    Runescape Gambling

    Offlinetyb97

    • Member
    • ****
    • Posts: 6,195
    • Thanks: +0/-0
      • View Profile
    Re: Timed Event System - Requesting feedback
    « Reply #3 on: September 15, 2014, 02:16:47 PM »
    I'm not sure how efficient or safe creating a new thread for each event is. However, nice use of parallelism.
    I assume you mean creating a new thread for every parallel event as the normal ones run on the same thread?
    As you can see I'm catching the exception if there would be to many threads, but according to my research a simple computer can run
    over a K threads so I don't think that would be a problem very quick.
    I didn't know those numbers, but looks good.

    The only other thing I see is it just seems a bit verbose to me. Couldn't you simplify things like this
    Code: Java
    1.         /**
    2.          * Disposes the event manager.
    3.          */
    4.         publicvoid dispose(){
    5.                 synchronized(parallelThreads){
    6.                         for(Iterator<EventThread> iterator = parallelThreads.iterator(); iterator.hasNext();){
    7.                                 ((EventThread)iterator.next()).dispose();
    8.                                 iterator.remove();
    9.                         }
    10.                 }
    11.                 parallelThreads.clear();
    12.                 logger.info("Event manager has been disposed.");
    13.         }
    14.  

    with using lambdas, parallelStream(), forEach(), etc?

    https://stackoverflow.com/questions/16635398/java-8-iterable-foreach-vs-foreach-loop

    Did some extra research since I haven't personally used them in this way yet, only seen it.
    what if i want to stick it in? you got a problem with that?

    OfflineDavidi2

    • Member
    • ****
    • *
    • Posts: 23,272
    • Thanks: +0/-0
      • View Profile
    Re: Timed Event System - Requesting feedback
    « Reply #4 on: September 15, 2014, 02:53:24 PM »
    Code: Java
    1.                 if(event.getDelay()<=0){
    2.                         logger.warning("Delay must be positive.");
    3.                         return;
    4.                 }
    You should instead check this value on the Event initialization in the constructor and throw a potential IllegalArgumentException

    Also I don't really like the design of using a list to wrap the event properties. Right now you are using an enum list to basically wrap 3 booleans because you would rather have a List than those booleans themselves. While it make look more elegant/cool isn't really a good reason to do it. If you realllly don't want to just add those booleans then at least use java.util.Properties

    I don't know a lot about the specifics with threads and such, but at first glance it also looks like this would be a crazy cpu hog, because it never sleeps. You should calculate how long each thread can sleep during the tick

    Lastly, is there any reason you have 'current' as a persistent variable outside of the tick method for events? It just seems like it's unneeded.



    OfflineRandQm

    • Member
    • ****
    • Posts: 4,220
    • Thanks: +0/-0
      • View Profile
    Re: Timed Event System - Requesting feedback
    « Reply #5 on: September 15, 2014, 03:38:25 PM »
    Code: Java
    1.                 if(event.getDelay()<=0){
    2.                         logger.warning("Delay must be positive.");
    3.                         return;
    4.                 }
    You should instead check this value on the Event initialization in the constructor and throw a potential IllegalArgumentException

    Also I don't really like the design of using a list to wrap the event properties. Right now you are using an enum list to basically wrap 3 booleans because you would rather have a List than those booleans themselves. While it make look more elegant/cool isn't really a good reason to do it. If you realllly don't want to just add those booleans then at least use java.util.Properties

    I don't know a lot about the specifics with threads and such, but at first glance it also looks like this would be a crazy cpu hog, because it never sleeps. You should calculate how long each thread can sleep during the tick

    Lastly, is there any reason you have 'current' as a persistent variable outside of the tick method for events? It just seems like it's unneeded.
    Thanks for the bunch of feedback, once I made changes I will update the topic.
    There's no reason why the current variable is outside the tick other than an oversight.
    About the properties, it's not because it's more fancy but because it is easier to read/use for a layman imo.



    I'm not sure how efficient or safe creating a new thread for each event is. However, nice use of parallelism.
    I assume you mean creating a new thread for every parallel event as the normal ones run on the same thread?
    As you can see I'm catching the exception if there would be to many threads, but according to my research a simple computer can run
    over a K threads so I don't think that would be a problem very quick.
    I didn't know those numbers, but looks good.

    The only other thing I see is it just seems a bit verbose to me. Couldn't you simplify things like this
    Code: Java
    1.         /**
    2.          * Disposes the event manager.
    3.          */
    4.         publicvoid dispose(){
    5.                 synchronized(parallelThreads){
    6.                         for(Iterator<EventThread> iterator = parallelThreads.iterator(); iterator.hasNext();){
    7.                                 ((EventThread)iterator.next()).dispose();
    8.                                 iterator.remove();
    9.                         }
    10.                 }
    11.                 parallelThreads.clear();
    12.                 logger.info("Event manager has been disposed.");
    13.         }
    14.  

    with using lambdas, parallelStream(), forEach(), etc?

    https://stackoverflow.com/questions/16635398/java-8-iterable-foreach-vs-foreach-loop

    Did some extra research since I haven't personally used them in this way yet, only seen it.
    I have used lambdas when programming with Linq, though it can look clean I find the readability not that good, especially for people who don't know lambda's so I prefer not to use them.
    soldout

    contact me on [email protected] if you're looking for me

    OfflineDavidi2

    • Member
    • ****
    • *
    • Posts: 23,272
    • Thanks: +0/-0
      • View Profile
    Re: Timed Event System - Requesting feedback
    « Reply #6 on: September 15, 2014, 03:51:47 PM »
    About the properties, it's not because it's more fancy but because it is easier to read/use for a layman imo.
    What do you mean? If you mean getProperties().contains(IMMEDIATE) is easier to read/use than isImmediate() then I disagree :P

    OfflineRandQm

    • Member
    • ****
    • Posts: 4,220
    • Thanks: +0/-0
      • View Profile
    Re: Timed Event System - Requesting feedback
    « Reply #7 on: September 15, 2014, 04:07:09 PM »
    About the properties, it's not because it's more fancy but because it is easier to read/use for a layman imo.
    What do you mean? If you mean getProperties().contains(IMMEDIATE) is easier to read/use than isImmediate() then I disagree :P
    Users would only need to put properties in as parameter when creating a new event, EventProperty.SOMETHING is easier than getting the correct string for the util.properties
    soldout

    contact me on [email protected] if you're looking for me

    OfflineDavidi2

    • Member
    • ****
    • *
    • Posts: 23,272
    • Thanks: +0/-0
      • View Profile
    Re: Timed Event System - Requesting feedback
    « Reply #8 on: September 15, 2014, 04:08:30 PM »
    Ok, but what about the other part of what I said, as in not actually using a list/map at all, and just using separate booleans?

    OfflineRandQm

    • Member
    • ****
    • Posts: 4,220
    • Thanks: +0/-0
      • View Profile
    Re: Timed Event System - Requesting feedback
    « Reply #9 on: September 15, 2014, 04:14:33 PM »
    Ok, but what about the other part of what I said, as in not actually using a list/map at all, and just using separate booleans?
    Yeah the list is maybe not necessary


    edit: Updated the code on the topic
    « Last Edit: September 15, 2014, 04:27:47 PM by RandQm »
    soldout

    contact me on [email protected] if you're looking for me

    OfflineLothy

    • Member
    • ****
    • *
    • *
    • Posts: 7,006
    • Thanks: +0/-0
      • View Profile
    <&Speljohan_> i wouldnt want to live in a society where Mopman isnt monitored 24/7

    OfflineAshi

    • Member
    • ****
    • Posts: 3,584
    • Thanks: +0/-0
      • View Profile
    Re: Timed Event System - Requesting feedback
    « Reply #11 on: September 17, 2014, 07:49:50 AM »
    http://docs.oracle.com/javase/tutorial/essential/concurrency/executors.html
    Would that be appropriate for events though. I though executors are best for task systems because you're not creating a new thread for each task.

    OT: It's good practice to use braces when you can.


    Edit: Just realised that this isn't an event system. It's a task system.

    OfflineRandQm

    • Member
    • ****
    • Posts: 4,220
    • Thanks: +0/-0
      • View Profile
    Re: Timed Event System - Requesting feedback
    « Reply #12 on: September 17, 2014, 11:23:38 AM »
    http://docs.oracle.com/javase/tutorial/essential/concurrency/executors.html
    Would that be appropriate for events though. I though executors are best for task systems because you're not creating a new thread for each task.

    OT: It's good practice to use braces when you can.


    Edit: Just realised that this isn't an event system. It's a task system.
    Yeah I realized it as well while reading your first line lol
    soldout

    contact me on [email protected] if you're looking for me

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal