Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: A new CB reader

by marioroy (Priest)
on Jul 07, 2017 at 20:18 UTC ( #1194533=note: print w/replies, xml ) Need Help??


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

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://1194533]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2017-10-20 08:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (259 votes). Check out past polls.

    Notices?