OS X kqueue based WatchService
Michael Hall
mik3hall at gmail.com
Mon Jun 24 14:33:17 PDT 2013
> It processes the events and then does this...
> key = watcher.poll(2, TimeUnit.SECONDS);
Sorry, my prior needed some proof reading. Let me know if anything in it needs more clearing up.
One other thing I did is to extend the above LotsOfEvents nio.2 test timeout to greater than 2 seconds.
For as long as the above polling waits - kqueue returns nothing, in debugging this looks like…
2013-06-23 12:51:23.264 java[1879:5103] going into kevent
2013-06-23 12:51:24.267 java[1879:5103] n 0 keepThreadRunning: YES
2013-06-23 12:51:24.269 java[1879:5103] going into kevent
2013-06-23 12:51:25.273 java[1879:5103] n 0 keepThreadRunning: YES
2013-06-23 12:51:25.275 java[1879:5103] going into kevent
2013-06-23 12:51:26.279 java[1879:5103] n 0 keepThreadRunning: YES
It keeps returning to my code having processed no additional events, "n 0".
Having an event looks more like…
2013-06-23 12:51:38.032 java[1879:5103] going into kevent
2013-06-23 12:51:38.064 java[1879:5103] n 1 keepThreadRunning: YES
2013-06-23 12:51:38.118 java[1879:5103] postJava 157
postNativeEvent: foo1 8 Thread[Thread-0,5,main]
Thanks again,
Michael Hall
trz nio.2 for OS X http://www195.pair.com/mik3hall/index.html#trz
HalfPipe Java 6/7 shell app http://www195.pair.com/mik3hall/index.html#halfpipe
AppConverter convert Apple jvm to openjdk apps http://www195.pair.com/mik3hall/index.html#appconverter
>
> I'm assuming to give the watch service implementation to queue up more events if they haven't all been processed. kqueue usually only seems to have process 30-45 or so at this point. For some reason during this two seconds kqueue does nothing The test fails for not having overflowed or processing all events.
> After the exception is thrown, kqueue resumes posting events until the code actually shuts down after the error. It appears to come out of the 'block' like something has been released, but what?
>
>> Also, I can't quite tell why you are calling kevent64 with a timeout of 5 seconds. Is this to workaround something else?
> This is what the code I based my native on did. After two timeouts it quits. For the testing I'm doing so far this has been no problem. For longer use that will probably have to change, I am not actually using this for anything yet. It does allow clean shutdown of the kqueue daemon for testing.
> I have shortened the timeout to 1 second in testing and it then does not block but returns a couple times with no events passed from the kernel. So if it is blocking it isn't my code but the the kernel queueing that is blocked? It is not processing in this time period for some reason - while the AbstractWatchService is being polled for results - about 3 seconds or so int total.
>
>>
>> Assuming you are extending AbstractWatchService "framwork" then the thread should be blocked waiting for events without any timeout. The timeout might nothing to do with the issue you are seeing, I'm only asking about it as I don't quite understand why it is is needed.
>
> Did that explain the test and my timeouts?
>
> Michael Hall
>
> trz nio.2 for OS X http://www195.pair.com/mik3hall/index.html#trz
>
> HalfPipe Java 6/7 shell app http://www195.pair.com/mik3hall/index.html#halfpipe
>
> AppConverter convert Apple jvm to openjdk apps http://www195.pair.com/mik3hall/index.html#appconverter
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20130624/b0fb5717/attachment.html
More information about the nio-dev
mailing list