salut,
What is best for handler in the future, base class or interface.
if we decide to do the isactive in comethandler, im experimenting with that
atm,
its gives "free" isactive check compared to the current very costly one,
all implementations need to have something like:
private volatile boolean isactive = true;
public boolean isActive() {
return isactive;
}
public void setActive(boolean isactive) {
this.isactive = isactive;
}
the problem is that people must remember to have a threadsafe boolean, ie
volatile.
also when using executors, that imo should be the default in todays world of
multicore, threadsafe code is needed too in comethandler,
and doing that by synchronizing on object instance level is not nice, that
makes worker threads pile up after each other ,
waiting for the earlier event to complete, possible multiple io messages
etc..
an entire threadpool can be blocked due to 1 slow client....
thats where my comethandler logic is needed, to only let the first
workerthread stay and do the work, with a private event queue datastructure
for that handler,
other worker threads simply add their event to that queue and return, not
blocking for IO etc..
And having all comethandlers to implement, copy paste that everytime is not
so good... its no OO way of coding and gives alot of room for errors.
a base class for comethandler can solve these problems.
what are your opinions ?
regards
gustav trede