« first day (1520 days earlier)      last day (3404 days later) » 

4:00 PM
o:
 
@fge Ok, thanks.
Inner classes are tricky because, given a string like "java.lang.invoke.MethodHandles.Lookup", technically, there's no way to tell whether it's an inner class or not.
"MethodHandles" could be a package name.
 
IDK, expect all the classes to follow semantics?
So, [a-z](?>[A-Z][a-z]*)* makes it part of a package name, while (?>[A-Z][a-z]*)+ makes it a type name
 
Maybe. I don't want to force the user to use correct capitalization.
 
4:34 PM
Maybe you could have it recursively search... but that sucks.
 
fge
Honestly, asking the user to capitalize is better imho
I mean, if you ask for String, and it gives you an alternative which is DocFlavor.STRING, your eyes widen
Mine do, at least
 
O-o
 
@fge Well, what I'd like to do is first perform a case-sensitive search. Then, if no classes are found, perform a case-insensitive search.
That's how it works when querying for classes.
=javadoc String
 
@Michael java.lang.String: The String class represents character strings. All string literals in Java programs, such as "abc", are implemented as instances of this class. (1/12)
 
=javadoc string
 
4:39 PM
Which one do you mean? (type the number)
1. java.lang.String
2. javax.print.DocFlavor.STRING
 
This is A++.
 
1
 
@Michael java.lang.String: The String class represents character strings. All string literals in Java programs, such as "abc", are implemented as instances of this class. (1/12)
 
fge
@Michael uhm, OK, why not
 
While we're at it, @Mic @fge do you want a @javaroom.website email? I'm still wrenching the mail forwarding DNS, plus it's free!
 
4:40 PM
@fge Why not what
 
@Michael the way you did thing :P
 
@Unihedro Sure! :D
 
fge
@Unihedro why not
 
@Unihedro Huh?
 
pls send email to admin@javaroom.website to confirm your email along with the username before the @ you want to use.
 
fge
4:41 PM
@Michael the way you implemented it; I am of the opinion that the user SHOULD do some work ;)
 
^^
 
I disagree. It's a chat room...you want to type stuff quickly.
 
=javadoc AClassWithAReallyLongName
 
@Unihedro Sorry, I never heard of that class. :(
 
@OakBot You'll know of it later when I feed you the JChatExchange docs, muahahahaha!!!
 
4:42 PM
@Unihedro Type =help to see all my commands.
 
cough
 
fge
@Unihedro sent
@Unihedro I told fge
Not fga
:p
 
Ugh, typo. :P One second...
 
@fge :P
 
You can have both, because I can't figure out how the erase the last. :|
Just kidding, found it.
I really should back up the configuration because it would suck if I do something stupid and lose it.
Done! I should go to sleep sometime soon; last day of school before christmas holidays tomorrow.
 
4:53 PM
=shutdown
 
Shutting down. See you later.
 
@Unihedro Yay!
 
OakBot Online.
 
fge
@Unihedro replied
 
=javadoc Exception(Throwable)
 
4:54 PM
@Michael Exception(Throwable cause): Constructs a new exception with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause). This constructor is useful for exceptions that are little more than wrappers for other throwables (for example, java.security.PrivilegedActionException).
 
There. :D
 
Lol ;D
 
fge
@Michael that links to the class, not the method
 
=javadoc ScheduledFuture#cancel()
 
I couldn't find a zero-arg signature for that method. Did you mean one of these? (type the number)
1. #cancel(boolean)
 
4:55 PM
@fge Yeah, I know.
1
 
@Michael boolean cancel(boolean mayInterruptIfRunning): Attempts to cancel execution of this task. This attempt will fail if the task has already completed, has already been cancelled, or could not be cancelled for some other reason. If successful, and this task has not started when cancel is called, this task should never run. If the task has already started, then the ...
mayInterruptIfRunning parameter determines whether the thread executing this task should be interrupted in an attempt to stop the task. (1/2)
 
Off to lunch. Later all.
 
fge
@Michael do I understand that the status of an incomplete javadoc query remains for as long as the user doesn't give a choice?
 
@fge It hangs around for 30 seconds. The timer resets everytime someone types a number.
 
@Michael nice noms :P
 
4:58 PM
@Unihedro Thanks xD
 
fge
@Michael OK
 
5:29 PM
@Unihedro The mid air jumping is intentional although you only can jump once. For the crashing at the last level, well thats because there is no next level but there will be at release.
 
ok!
 
5:52 PM
OK, really late, sleep is way overdue. :P Night!
 
fge
6:27 PM
thinks his java.nio.file page is still not easy enough to follow
I've been using the API for too long :(
 
user1648409
6:37 PM
Hi @fge: Can i ask you again 2 things about ExecutorServices ?
 
fge
@Shiuyin sure
 
user1648409
How do i instantiate the ExecutorServices? You told me yesterday, that i need ExecutorService for the SenderThread and an ScheduledExecutorService for the schedulerThread. Ive tried something like ExecutorService sender = Executors.newSingleThreadExecutor() - is that correct? What do i need for the scheduler?
 
ohh dear... what is the question there??
=javadoc Executors
 
@Vogel612 java.util.concurrent.Executors: Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory, and Callable classes defined in this package. This class supports the following kinds of methods: Methods that create and return an ExecutorService set up with commonly useful configuration settings. Methods that create and ...
return a ScheduledExecutorService set up with commonly useful configuration settings. Methods that create and return a "wrapped" ExecutorService, that disables reconfiguration by making implementation-specific methods inaccessible. Methods that create and return a ThreadFactory that sets newly created threads to a known state. Methods that create and return a Callable out of other closure-like forms, so they can be used in execution methods requiring Callable.
 
@Shiuyin there you go ^^
 
user1648409
6:41 PM
lol
 
hmm possible feature-request: method summary
 
user1648409
so i guess private final ScheduledExecutorService scheduler =
Executors.newScheduledThreadPool(1); is the way to go for me?
 
there is even: Executors.newSingleThreadScheduledExecutor()
 
user1648409
hm
 
user1648409
@fge: I'm having trouble implementing that it throttles the messages per user not in general. What is the way to go here? I guess i need 1 sender thread and one scheduler thread per user? My first guess would be to instantiate those 2 threads whenever a new user joins and bind them to the user-specific queue. is that the way to go?
 
fge
6:48 PM
@Shiuyin hold on for a few minutes
 
user1648409
okay! thanks again in advance :)
 
fge
@Shiuyin first of all you should have a class implementing Runnable
This will be a class which you will instantiate for each new client
Now, what I don't know yet is how you dispatch the messages
 
user1648409
ah, so you want to have ONE network scheduler per user
 
fge
How do you decide when there's a new client?
No
 
user1648409
i thought i would do one NetworkScheduler per all users
 
fge
6:49 PM
Only one scheduler
 
user1648409
wait, let me paste bin what i did so far
 
fge
You should have several classes
Don't try and stuff it all into one class, this will just be confusing
 
user1648409
pastebin.com/Fsy8KKiL
 
fge
@Shiuyin too much stuff in only one class
@Shiuyin separate the roles
One class for a client, which implements Runnable
One class for the scheduler
One class for the "coordinator"
And you still haven't told how you decided on which clients were created -- or even whether they should be ripped out at any time
 
user1648409
hum...
 
user1648409
6:54 PM
wait, give me a sec
 
user1648409
Ok, ill try to explain it again. I am trying to write a class, that sends messages to the connected clients via web sockets and automatically throttles the amount of messages being sent. a "Message" is a class which has a token to the client it should be sent to. Therefore i know where to sent it. So i implemented a HashMap mapping between the Token and the message queue for each client. I simply want to be able to call addMessage() on the NetworkScheduler class and it will be done
 
user1648409
i don't quite understand what you mean by one class for the client. What would that "client" be doing? One instance of it per connected user? what would your "one class per scheduler" contain?... O,o
 
fge
That's not the question I was asking
The question I was asking is when, where and how do you decide that a new client should be created
 
user1648409
when a new client connects to the server and a new user token is generated
 
fge
OK, and which class takes care of that?
 
user1648409
7:02 PM
i have a class called Server, that is a WebSocketServer and has an onOpen() function for incoming new connections. And i have a Token class that generates unique Tokens for new users
 
user1648409
github.com/TooTallNate/Java-WebSocket
 
fge
OK, and who will receive the messages for each client?
This is what I don't quite get
I haven't done websockets, so I don't really understand what happens there
 
user1648409
Ok, ill try to explain it. The Server class handles all incoming messages by the Clients and calls the appropriate functions. Those functions decide what the server should do and which clients it should send an answer and which answer (which content). For each connected User there is a private WebSocket connection saved via i can sent answers back. So when i give a Message message to the NetworkScheduler i want him to just lookup the WebSocket connection for this message's receptor and send the
2
 
user1648409
message content to that Connection
 
user1648409
That is already working and done by myself. i only have a lot of trouble doing that throttling network stuff
 
fge
7:08 PM
OK, so the Server class dispatches to the clients
 
user1648409
yes!
 
fge
That's what I wanted to know
 
user1648409
then sorry i didn't understand that earlier ...
 
fge
And the identifier for each client is a Token, right?
 
user1648409
correct
 
fge
7:09 PM
Which means you should have a Map<Token, BlockingQueue<Message>> somewhere
 
user1648409
Correct! That is implemented in our networkScheduler class
 
user1648409
which i pastebin'ed
 
fge
Why, if it is the Server class which dispatches messages?
It makes no sense to have that in the scheduler thread
OK, so we'll step back a little
 
user1648409
because the gameLogic is happening in the Server class and i want to divide the game logic from the Throttling logic - this is why i made the NetworkScheduler class
 
fge
Which is exactly why it makes no sense for the scheduler class to handle message dispatch
 
7:12 PM
~JavaBot at your service
 
user1648409
Enlighten me please ! :D
 
**help timer
@Vogel612 I am JavaBot, maintained by Uni, Vogel, and a few others. You can find me on github.com/Vincentyification/JavaBot
hmm.. failed..
 
fge
@Shiuyin as I said, let's have a step back
 
user1648409
im not native speaker, what do you mean by "step back"?
 
fge
@Shiuyin that is, let's pause for a moment and consider what we want to do
 
user1648409
7:18 PM
okay
 
fge
(I'm no native speaker either by the way)
So, you have three classes
The Server class which is in charge of: 1. creating new clients when necessary; 2. dispatch incoming messages
 
~JavaBot at your service
 
fge
The Client class which is a class implementing Runnable, and which is in charge of sending messages
 
user1648409
yes, except that Server doesn't create new Clients he just handles incoming new connections and stores them and incoming messages and handles them
 
user1648409
ok
 
fge
7:20 PM
So who is creating the clients then?
 
user1648409
Okok, if you understand it that way, then the Server is creating the Clients, yes
 
fge
There is no "if you understand it that way"
Either it doesn't or it does
There's no inbetween here
 
user1648409
yes ok, then it does
 
okay I think I got the timer-functionality working in a prototypal state...
It needs some ironing out, but you're all welcome to test it in the sandbox.
 
fge
@Shiuyin moving on now
@Shiuyin since you have more than one client it means you have more than one Semaphore
 
user1648409
7:32 PM
yes, correct
 
fge
@Shiuyin therefore the Server class should also initialize the NetworkScheduler class and the latter should be aware of all semaphores
Therefore the semaphores should be in a thread safe list
Put them in a CopyOnWriteArrayList
 
user1648409
uhm ok
 
user1648409
so the semaphore list would still be in my NetworkScheduler class
 
fge
So, each time you have to create a new client, you have to: 1. create a new Token, a new BlockingQueue and a new Semaphore; 2. add that Semaphore to the COW list (which is shared with the scheduler); 3. create a new client with the queue as an argument; 4; put the Token, BlockingQueue pair in the map; 5. schedule the new Client into an unbounded ExecutorService
Yes, but shared with the server class
The scheduler class would iterate over this list and "reset" the semaphores
 
user1648409
uhm ok
 
user1648409
7:37 PM
will do that, give me some time :D
 
user1648409
thanks!
 
fge
Wait wait wait
How about client disconnection? Does it ever happen? If yes, where and how it is handled?
Ohwell, let's save that for later
 
user1648409
yes yes, i will add that
 
user1648409
i understand what you mean
 
user1648409
don't worry ^^
 
fge
7:38 PM
I do worry
Too much so, probably
 
user1648409
meh, i guess im looking like a noob i guess
 
fge
Oh, and the client should also have the semaphore as an argument
Not only the queue
(you do recall the loop for the client, right?)
 
user1648409
yes
 
user1648409
7:52 PM
anyway, thanks for your explanations. will try now...
 
I feel so frigging awesome right now...
 
fge
@Vogel612 hmm?
 
Language thinking, calculational thinking, pictural / 3d thinking
 
fge
8:15 PM
Eh well, at the moment I have a more pressing matter -- I still can't figure out DI correctly
 
8:37 PM
maybe I can help?
 
fge
Yes, maybe
If you have the time to spare I'd appreciate
 
@fge Can you just ask?
 
fge
OK, well, here I go
In java7-fs-base, I am sure that I'd have an easier time testing if I could DI some factories
Note that I don't mind adding javax.inject as a compile time dependency
 
9:46 PM
hello guys... have any clue about this question stackoverflow.com/questions/27591134/…
 
10:20 PM
@fge Started to implement a ByteStream
actually it's a pain
so much hidden classes
I don't think its a good idea finally
the over alternative would be to use composition an wrap it in an IntStream ensuring each value is in the range of Byte
but I have no idea of how to start atm
 
fge
10:41 PM
@ZouZou that would be worth an SO question... I have tried to inquire a bit and what with those AbstratPipelines and stuff... Mind you, it was the same for FileSystem and Path and I did manage to create a library ;)
But yeah, it's very, very hard work
 
The problem is that I'm scared to implement something wrong.
I'll start with composition and see how it works.
ByteStream filter(BytePredicate predicate) {
        wrapper.filter(new IntPredicate() {
            @Override
            public boolean test(int value) {
                return predicate.test((byte) value);
            }
        });
        return this;
    }
with wrapper an IntStream
do you think it's viable?
cleaner :
ByteStream filter(BytePredicate predicate) {
        wrapper.filter(i -> predicate.test((byte)i));
        return this;
    }
 
fge
I don't know, ultimately is it really worth it if we don't get to the core of it?
 
you mean it's not* really worth it?
yes I agree
 
fge
Meh, maybe someone will be courageous enough to delve into it
But java.nio.file has the same problem
Path has a s*load of methods
And no helpers
Not even a builder like Stream has ;)
And I had to implement it all by myself
 
well it's courageous
 
fge
10:48 PM
That was worth the time spent though, since after that I could develop two entire filesystems in not even 10 days
 
I must admit
 
fge
That is not as involved as developing a Stream from scratch though
 
I'll start with this version
IMO this is not so bad to use composition
as byte is a subset of integer
in terms of values
so basically it's just an IntStream with a restriction on the range of its values
 
fge
Well, if you look at CharSequence they didn't bother
It has a .chars() method which returns an IntStream
Even though what is returned is ultimately chars
 
yet
yep
that's the spirit behind the design
 
fge
10:50 PM
So you can do "mystring".chars().forEach() etc
 
and that's why we don't have CharStream/ByteStream/FloatStream
 
fge
Char and Float I can understand; Byte, though, could be useful
Unless they decided that {Input,Output}Stream were good enough?
Apart from that there may be some interest in statistics too
 
for?
 
fge
Gaussian distributions for instance
In fact I believe MANY mathematical operators can be Collectors
THAT would be a great library to have, I believe
What do you think?
 
Yes its true and it could be fun to implement it
 
fge
11:03 PM
And it requires learning some math stuff, heh
I know the basics but not much beyond that ;)
 
Ah!
I had a probablity and statistics course last year
 
fge
Lucky you
 
yeah I liked it
unfortunately I failed physics course
so I have to repass the exam
 
fge
Meh, my education is pretty poor
But stuff like this... I'm interested
 
if you have the curiosity it's enough
motivation + curiosity = epic win
 
fge
11:15 PM
I did program some cool stuff with regards to fluent programming and can replicate it; for instance, ProcessorMap.create().when(somePredicate).then(someAction).when(p2).then(a2).etc‌​().etc().otherwise(defaultAction)
Make some stuff like this to generate Collectors and you can have pretty cool stuff
The problem is to make this at the same time general enough and easy enough to use
 
to make it lazy?
 
fge
Well, that's a Collector, so the main thing is to have such stuff work even when the Stream has the possibility to be truly .parallel()
In fact I was thinking about a generalization of Collectors.groupingBy()
(I'm still convinced something can be done with streams and block ciphers though)
Hmm, I know
Take an InputStream as an argument and return a Stream<byte[]> where the size of individual byte arrays is decided at construction
 
11:41 PM
Finished
thoughts?
ByteSummaryStatistics are not implemented yet but it will come
looks cool
I just have a problem with trySPlit in the spliterator
dunno how to fix atm
 
fge
@ZouZou sorry, I was away
Looking up
Uh, to be honest I didn't think you'd just go and do it :p
@ZouZou I'd rather have named the instance variable delegate instead of wrapper
 
ah ye
 
fge
Its current name kind of... Says the opposite of what it is, no?
 
oh i'm bad at variable naming
yeah
delegate is largely more accurate
 
fge
I'm impressed that you did it in that little time though!
 
11:54 PM
I just copy pasted the IntStream interface
made it a class
and fix the compile errors :D
not so long cause the functional interface are rather short and already implemented as int
refactor for the win
 
fge
Well, I have other ideas, but heh
 
eh the % operator does not promote both operand to int?
I need to do ByteStream.iterate((byte)0 , x -> (byte)(x + 1))
but filter(i -> i % 2 == 0)
 
fge
Right now I'm on this
 

« first day (1520 days earlier)      last day (3404 days later) »