Ignore:
Timestamp:
07/16/13 23:31:35 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

for Joinables running

CHANGELOG:
Add WorkPackageLogic? and classes representing prime experiment state.

Add classes for PrimeExperiment? state.

Extract single netload routine in Simulator.

Working netload with dummy content in PrimeExperiment?.

More development with NetLoadSaveLogic? and PrimeExperiment?.

Improvement around prime.

Improve BufferedDispatcher?.isActive logic.

Add prime-all.xml configuration.

Manual connecting to existing simulators from GUI.

Guard in SimulatorConnector? against expdef mismatch.

Guard against empty target dispatcher in BufferedDispatcher?.

Make BufferedDispatcher? a Dispatcher (and Joinable).

Minor improvements.

Done StackedJoinable?, improve Experiment.

Develop StackedJoinable?.

Add StackedJoinable? utility joinables controller.

Add dependency on apache-commons-lang.

Add ready ListChange? on Simulators.

Improve hints in ListChange?.

Several improvements.

Found bug with dispatching in Experiment.

Minor improvements.

Fix bug with early finishing Server.

Many changes in Dispatching.

Fix bug with connection.

Do not obfuscate log with socket related exceptions.

Add SocketClosedException?.

Add SimulatorConnector?.

Work out conception of experiment composing of logics building blocks.

Rename SinkInterface? to Sink.

Move saving of Accesses into AccessOperations?.

Some improvements to Experiment.

Improve joinables.

Fix issue with joinables closing.

Add direct and managed consoles to popup menu.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/util/dispatching/Dispatching.java

    r101 r102  
    33import java.util.Timer;
    44
     5import org.apache.logging.log4j.Level;
    56import org.apache.logging.log4j.Logger;
    67import org.apache.logging.log4j.LogManager;
    78
    89import com.framsticks.util.FramsticksException;
     10import com.framsticks.util.Misc;
    911
    1012/**
     
    3234        }
    3335
     36        public static <C> void dispatch(Dispatcher<C> dispatcher, RunAt<? extends C> runnable) {
     37                dispatcher.dispatch(runnable);
     38        }
     39
    3440        // public static boolean assertInvokeLater(Dispatcher dispatcher, RunAt runnable) {
    3541        //      dispatcher.invokeLater(runnable);
     
    6672
    6773        public static void use(final Joinable joinable, final JoinableParent owner) {
     74                Misc.throwIfNull(joinable);
    6875                log.debug("using {} by {}", joinable, owner);
    6976                if (joinable.use(owner)) {
     
    7582
    7683        public static void drop(final Joinable joinable, final JoinableParent owner) {
     84                Misc.throwIfNull(joinable);
    7785                log.debug("droping {} by {}", joinable, owner);
    7886                if (joinable.drop(owner)) {
     
    8492
    8593        public static void join(Joinable joinable) throws InterruptedException {
     94                Misc.throwIfNull(joinable);
    8695                log.debug("joining {}", joinable);
    8796                try {
     
    95104
    96105        public static void childChangedState(final JoinableParent parent, final Joinable joinable, final JoinableState state) {
    97                 if (state.ordinal() <= JoinableState.RUNNING.ordinal()) {
     106                if (state.ordinal() < JoinableState.RUNNING.ordinal()) {
    98107                        return;
    99108                }
     
    113122                        }
    114123                } catch (InterruptedException e) {
     124                        log.debug("failed to wait on {} because of: {}", object, e.getMessage());
    115125                }
    116126        }
     
    123133                                return;
    124134                        } catch (InterruptedException e) {
     135                                log.debug("failed to join {} because of: {}", joinable, e.getMessage());
    125136                                // throw new FramsticksException().msg("failed to join").arg("dispatcher", dispatcher).cause(e);
    126137                        }
     
    192203
    193204        // public static class DispatcherWaiter<C, T extends Dispatcher<C> & Joinable> implements Dispatcher<C> {
    194         //      // protected boolean done = false;
    195         //      protected final T dispatcher;
    196         //      protected RunAt<? extends C> runnable;
    197 
    198         //      /**
    199         //       * @param joinable
    200         //       */
    201         //      public DispatcherWaiter(T dispatcher) {
    202         //              this.dispatcher = dispatcher;
    203         //      }
    204 
    205         //      public synchronized void waitFor() {
    206         //              while ((runnable == null) && (dispatcher.getState().ordinal() <= JoinableState.RUNNING.ordinal())) {
    207         //                      try {
    208         //                              this.wait();
    209         //                      } catch (InterruptedException e) {
    210         //                      }
    211         //              }
    212         //              if (runnable != null) {
    213         //                      runnable.run();
    214         //              }
    215 
    216         //      }
    217 
    218         //      @Override
    219         //      public boolean isActive() {
    220         //              return dispatcher.isActive();
    221         //      }
    222 
    223         //      @Override
    224         //      public synchronized void dispatch(RunAt<? extends C> runnable) {
    225         //              this.runnable = runnable;
    226         //              this.notifyAll();
    227         //      }
     205        //      // protected boolean done = false;
     206        //      protected final T dispatcher;
     207        //      protected RunAt<? extends C> runnable;
     208
     209        //      /**
     210        //       * @param joinable
     211        //       */
     212        //      public DispatcherWaiter(T dispatcher) {
     213        //              this.dispatcher = dispatcher;
     214        //      }
     215
     216        //      public synchronized void waitFor() {
     217        //              while ((runnable == null) && (dispatcher.getState().ordinal() <= JoinableState.RUNNING.ordinal())) {
     218        //                      try {
     219        //                              this.wait();
     220        //                      } catch (InterruptedException e) {
     221        //                      }
     222        //              }
     223        //              if (runnable != null) {
     224        //                      runnable.run();
     225        //              }
     226
     227        //      }
     228
     229        //      @Override
     230        //      public boolean isActive() {
     231        //              return dispatcher.isActive();
     232        //      }
     233
     234        //      @Override
     235        //      public synchronized void dispatch(RunAt<? extends C> runnable) {
     236        //              this.runnable = runnable;
     237        //              this.notifyAll();
     238        //      }
    228239
    229240        // }
     
    284295        }
    285296
     297        public static <C> void dispatchLog(final Dispatcher<C> dispatcher, final Logger logger, final Level level, final Object text) {
     298                dispatcher.dispatch(new RunAt<C>(ThrowExceptionHandler.getInstance()) {
     299
     300                        @Override
     301                        protected void runAt() {
     302                                logger.log(level, "message dispatched into {}: {}", dispatcher, text);
     303                        }
     304                });
     305
     306        }
     307
    286308}
Note: See TracChangeset for help on using the changeset viewer.