New work-in-progress thread management

33 views
Skip to first unread message

Sergio Bossa

unread,
Jun 16, 2012, 8:58:45 AM6/16/12
to jour...@googlegroups.com
Hi journalers,

as mentioned on another mailing list thread (but thought it would be
worth to have a dedicated thread), I rewrote the thread management
code by allowing for externally set writer and disposer threads: this,
in order to avoid creating two new threads for each journal and so
enabling the use of a large number of different journals.

You can find the new code in this branch:
https://github.com/sbtourist/Journal.IO/tree/wip-executors

In order to share executors between journals, just call the setWriter
and setDisposer journal methods.

Any feedback would be highly appreciated :)
Cheers,

Sergio B.

--
Sergio Bossa
http://www.linkedin.com/in/sergiob

Martin Krasser

unread,
Jun 17, 2012, 2:03:26 AM6/17/12
to Journal.IO
Hi Sergio,

great that you added this feature. I'd like to change the new API from

void setWriter(ExecutorService writer)

to

void setWriter(Executor writer)

for the following reasons:

- DataFileAppender anyway uses the Executor interface of the writer
(managed or not)
- the ExecutorService interface is only used internally for managed
writers (writer.shutdown())
- this change allows usage of Akka dispatchers (which implement
Executor) as writers (would be a big benefit for my app)

Similar arguments apply to setDisposer as well.

WDYT?

Cheers,
Martin

Sergio Bossa

unread,
Jun 17, 2012, 4:19:19 AM6/17/12
to jour...@googlegroups.com
Hi Martin,

thanks for the feedback.

I used ExecutorService because I need to manually shutdown managed
ones, and the shutdown method is not on the plain Executor interface.
By the way, if that's important for you (and probably is for Viktor
too), I could use the Executor interface and safely downcast in case
of managed ones.

Keep you posted.
Cheers,

Sergio B.

Martin Krasser

unread,
Jun 17, 2012, 4:27:16 AM6/17/12
to jour...@googlegroups.com

Am 17.06.12 10:19, schrieb Sergio Bossa:
> Hi Martin,
>
> thanks for the feedback.
>
> I used ExecutorService because I need to manually shutdown managed
> ones, and the shutdown method is not on the plain Executor interface.

I know

> By the way, if that's important for you (and probably is for Viktor
> too), I could use the Executor interface and safely downcast in case
> of managed ones.

+1, this was my idea as well.

Thanks,
Martin
Martin Krasser

blog: http://krasserm.blogspot.com
code: http://github.com/krasserm
twitter: http://twitter.com/mrt1nz



Sergio Bossa

unread,
Jun 17, 2012, 7:07:04 AM6/17/12
to jour...@googlegroups.com
On Sun, Jun 17, 2012 at 7:03 AM, Martin Krasser <kras...@googlemail.com> wrote:

> Similar arguments apply to setDisposer as well.

The disposer is currently a ScheduledExecutorService, but it's not
clear to me which class you would like it to be: may you elaborate
more?

Sergio Bossa

unread,
Jun 17, 2012, 8:08:06 AM6/17/12
to jour...@googlegroups.com
Martin (and Viktor?),

So I switched the writer interface to a plain Executor while left the
disposer one untouched (not sure what you need it to be there).
I've also made some other improvements and added a rough test for
performances, which I'm happy to say look slightly better than the old
blocking implementation (probably because we're not using a blocking
queue anymore for batches).

Everything is on the wip-executors branch, any feedback will be highly welcome!

Martin Krasser

unread,
Jun 17, 2012, 11:11:20 AM6/17/12
to jour...@googlegroups.com

Am 17.06.12 13:07, schrieb Sergio Bossa:
> On Sun, Jun 17, 2012 at 7:03 AM, Martin Krasser <kras...@googlemail.com> wrote:
>
>> Similar arguments apply to setDisposer as well.
> The disposer is currently a ScheduledExecutorService, but it's not
> clear to me which class you would like it to be: may you elaborate
> more?

Somehow missed the special disposer.scheduleAtFixedRate usage in
DataFileAccessor, previously. Leaving it like that is completely fine
for. Sorry for the confusion.

Martin Krasser

unread,
Jun 17, 2012, 11:15:38 AM6/17/12
to jour...@googlegroups.com

Am 17.06.12 14:08, schrieb Sergio Bossa:
> Martin (and Viktor?),
>
> So I switched the writer interface to a plain Executor while left the
> disposer one untouched (not sure what you need it to be there).

That's exactly what I need (see my previous message). Thanks a lot.

> I've also made some other improvements and added a rough test for
> performances, which I'm happy to say look slightly better than the old
> blocking implementation (probably because we're not using a blocking
> queue anymore for batches).
>
> Everything is on the wip-executors branch, any feedback will be highly welcome!

I'll give it a try tomorrow and let you know.
Reply all
Reply to author
Forward
0 new messages