Thread: Hyperion Engine/Task system

Results 1 to 5 of 5
  1. #1 Hyperion Engine/Task system 
    Registered Member SuperMario's Avatar
    Join Date
    May 2012
    Posts
    329
    Thanks given
    30
    Thanks received
    26
    Rep Power
    5
    Why was this done?
    Code:
    public void submitLogic(final Runnable runnable) {
    		logicService.submit(new Runnable() {
    			public void run() {
    				try {
    					runnable.run();
    				} catch (Throwable t) {
    					System.err.println(t.getMessage());
    				}
    			}
    		});
    	}
    instead of

    Code:
    public void submitLogic(final Runnable runnable) {
    		logicService.submit(runnable);
    	}
    Am I overlooking something?
    I know it's not to try and catch as it already does that in the run method.
    So is it just to print the message when it catches the throwable?
    Code:
                         try {
    					final Task task = tasks.take();
    					submitLogic(new Runnable() {
    						@Override
    						public void run() {
    							task.execute(Engine.this);
    						}
    					});
    				} catch (InterruptedException e) {
    					continue;
    				}
    Reply With Quote  
     

  2. #2  
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,534
    Thanks given
    457
    Thanks received
    1,257
    Rep Power
    990
    You can't do this

    Code:
    public void submitLogic(final Runnable runnable) {
    		logicService.submit(runnable);
    	}
    runnable is an interface so you have to initialize it. And you know that interfaces can't be instantiated so they have to use signatures.

    Code:
    					final Task task = tasks.take();
    					submitLogic(new Runnable() {
    						@Override
    						public void run() {
    							task.execute(Engine.this);
    						}
    					});
    The try and catch can be optional depending if a method has thrown an excepting if it has then you'll have to use try and catch to catch the errors being thrown.

    Don't do this

    Code:
    catch (InterruptedException e) {
    					continue;
    				}
    You're saying that if an error is caught just skip it and continue. Print the error message so you know what could be causing a problem.
    Attached image
    Reply With Quote  
     

  3. #3  
    Registered Member SuperMario's Avatar
    Join Date
    May 2012
    Posts
    329
    Thanks given
    30
    Thanks received
    26
    Rep Power
    5
    So you can't pass a runnable to the scheduleLogic method? I havent tested it yet. The continue was already in hyperion btw.
    Reply With Quote  
     

  4. #4  
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,534
    Thanks given
    457
    Thanks received
    1,257
    Rep Power
    990
    Quote Originally Posted by SuperMario View Post
    So you can't pass a runnable to the scheduleLogic method? I havent tested it yet. The continue was already in hyperion btw.
    You can still pass it IF this method
    Code:
     submit
    has a parameter that accepts Runnable. But you're still gonna have to create a new Runnable and do some kind of logic anyway.

    Code:
    					final Task task = tasks.take();
    					submitLogic(new Runnable() {
    						@Override
    						public void run() {
    							task.execute(Engine.this);
    						}
    					});
    Quote Originally Posted by SuperMario View Post
    The continue was already in hyperion btw.
    Usually if there's an error, you'll stop the running task, not continue it while its got errors coming in.
    Attached image
    Reply With Quote  
     

  5. #5  
    Registered Member SuperMario's Avatar
    Join Date
    May 2012
    Posts
    329
    Thanks given
    30
    Thanks received
    26
    Rep Power
    5
    Code:
    submitLogic(new Runnable() {
    						@Override
    						public void run() {
    							task.execute(Engine.this);
    						}
    					});
    Here a runnable is created and passed. so why does scheduleLogic create a new runnable encapsulating the runnable that was passed in, seems kinda redundant.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 0
    Last Post: 07-09-2015, 12:15 AM
  2. [Hyperion] Basic PlayerListener system
    By The Eternity in forum Tutorials
    Replies: 10
    Last Post: 04-01-2013, 04:43 AM
  3. [Hyperion] Ground Item system
    By Shoes in forum Snippets
    Replies: 9
    Last Post: 04-27-2011, 06:34 AM
  4. Slayer Task System.
    By Bando in forum Snippets
    Replies: 5
    Last Post: 08-17-2010, 07:36 PM
  5. Perfect new engine chat system
    By Zee Best in forum Show-off
    Replies: 30
    Last Post: 01-31-2010, 02:36 AM
Tags for this Thread

View Tag Cloud

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •