Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: A new CB reader

by Discipulus (Monsignor)
on Jul 07, 2017 at 08:57 UTC ( #1194452=note: print w/replies, xml ) Need Help??


in reply to Re: A new CB reader
in thread A new CB reader

Thanks choroba!

I just forked it and proposed a modification ( just added some color / size options ).

Have you considered the possibility to use MCE for threading part? Will be an opportunity to show another example of usage of such module.

Unfortunately I'm not able to modify your program in this direction: possibly some other monks will accept the challenge..

Anyway thanks!



L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^3: A new CB reader
by marioroy (Priest) on Jul 07, 2017 at 20:18 UTC

    Hi Discipulus. Just few line changes ( 3 places ). Here's the diff output.

    $ diff pm-cb-g pm-cb-g-hobo 27,28c27,28 < use threads (stack_size => 2 ** $stack_size); < use Thread::Queue; --- > use MCE::Hobo; > use MCE::Shared; 41c41 < my ($readQ, $writeQ) = map 'Thread::Queue'->new, 1, 2; --- > my ($readQ, $writeQ) = map { MCE::Shared->queue() } 1, 2; 43c43 < my $communicate_t = threads->create(\&communicate); --- > my $communicate_t = MCE::Hobo->create(\&communicate);

    Update. The stack_size option isn't needed when using MCE::Hobo. Below is the diff -u output.

    $ diff -u pm-cb-g pm-cb-g-hobo --- pm-cb-g 2017-07-07 16:05:39.000000000 -0500 +++ pm-cb-g-hobo 2017-07-07 16:32:36.782646208 -0500 @@ -6,12 +6,11 @@ use Getopt::Long qw( :config no_ignore_case ); -my ($bg_color, $fg_color, $author_color, $font_name, $char_size, - $stack_size); +my ($bg_color, $fg_color, $author_color, $font_name, $char_size); BEGIN { ($bg_color, $fg_color, $author_color, $font_name, $char_size, - $stack_size) = qw( white black blue Helvetica 12 15 ); + ) = qw( white black blue Helvetica 12 ); die "Invalid arguments!\n" unless GetOptions( 'a|author_color=s' => \$author_color, @@ -19,13 +18,12 @@ 'c|char_size=i' => \$char_size, 'f|fg_color=s' => \$fg_color, 'F|font_name=s' => \$font_name, - 's|stack_size=i' => \$stack_size, ); } -use threads (stack_size => 2 ** $stack_size); -use Thread::Queue; +use MCE::Hobo; +use MCE::Shared; use constant { @@ -38,9 +36,9 @@ }; -my ($readQ, $writeQ) = map 'Thread::Queue'->new, 1, 2; +my ($readQ, $writeQ) = map { MCE::Shared->queue() } 1, 2; -my $communicate_t = threads->create(\&communicate); +my $communicate_t = MCE::Hobo->create(\&communicate); gui();

    Regards, Mario

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1194452]
help
Chatterbox?
[marto]: use libPD on Android/IOS, route to something listening on the pi :P
[marto]: libpd
[marto]: OSC
[Discipulus]: choroba i'm just behind you at 100 points

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2017-10-17 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (225 votes). Check out past polls.

    Notices?