MCE::Ch...l::Mutex(3)

✨ MCE::Channel::Mutex πŸ’–

okay bestie, gather round, because this is a Perl doc for MCE::Channel::Mutex, and it's part of the User Contributed Perl Documentation. it's giving "channels, but make it locked." let's get into it 🫢


🌸 NAME 🌸

MCE::Channel::Mutex β€” a Channel for producer(s) and many consumers ✨

πŸŽ€ VERSION πŸŽ€

This document describes MCE::Channel::Mutex version 1.902. yes, we're on 1.902, we're current, we're hydrated πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, this is a channel class that gives you queue-like and two-way communication for processes and threads. the locking? handled by MCE::Mutex. no cap, that's the whole job of this thing πŸ”₯

and the actual API β€” every method, every detail β€” lives over in MCE::Channel. go read that one for the full menu. this page is the Mutex-flavored implementation, iykyk πŸ’€

πŸ’« new

use MCE::Channel;

# The default is tuned for one producer and many consumers.
my $chnl_a = MCE::Channel->new( impl => 'Mutex' );

# Specify the 'mp' option for safe use by two or more producers
# sending or receiving on the left side of the channel (i.e.
# ->enqueue/->send or ->recv2/->recv2_nb).

my $chnl_b = MCE::Channel->new( impl => 'Mutex', mp => 1 );

okay so read that carefully bestie, because the vibe check matters here πŸ‘‘

  • the default is tuned for one producer and many consumers β€” that's the whole point of this class, it's literally in the NAME πŸŽ€
  • if you need two or more producers sending or receiving on the left side of the channel, you gotta pass the mp option. and when they say left side, they mean it β€” that's ->enqueue/->send or ->recv2/->recv2_nb. don't skip this or you're gonna have a bad time πŸ’€
ngl, if you're doing multi-producer on the left and you don't set mp => 1, that's not the move. it's right there in the example. be safe. 🫢

πŸ“ QUEUE-LIKE BEHAVIOR πŸ“

these are the queue-girlies of the channel πŸ’…:

  • enqueue
  • dequeue
  • dequeue_nb
  • end

🌈 TWO-WAY IPC - PRODUCER TO CONSUMER 🌈

producer talks, consumer listens, iconic behavior πŸ’–:

  • send
  • recv
  • recv_nb

🌸 TWO-WAY IPC - CONSUMER TO PRODUCER 🌸

and yes, the consumer can talk BACK. it's a two-way street, main character energy from both sides πŸ‘‘:

  • send2
  • recv2
  • recv2_nb

πŸ’œ AUTHOR πŸ’œ

Mario E. Roy, <marioeroy AT gmail DOT com> β€” thank you for this, we are obsessed 🫢✨


and that's the whole page bestie, no crumbs left πŸŽ€ this was perl v5.42.0, dated 2025-09-10, and the manpage title is MCE::Ch...l::Mutex(3). slay, go build something with channels, periodt πŸ’…πŸ¦‹

πŸ“¦ where this page comes from