21 #ifndef __SSRC_SPREAD_MAILBOX_H
22 #define __SSRC_SPREAD_MAILBOX_H
46 Timeout(
const Spread::sp_time time) : time(time) { }
57 Timeout(
const long sec = 0,
const long usec = 0) {
58 time.sec = sec, time.usec = usec;
66 operator Spread::sp_time()
const {
return time; }
170 Low = LOW_PRIORITY, Medium = MEDIUM_PRIORITY, High = HIGH_PRIORITY
174 bool _group_membership, _drop_receive, _killed;
175 string _connection, _name, _private_group;
176 descriptor_type _mbox;
182 explicit Mailbox(
const string & connection =
"",
const string & name =
"",
183 const bool group_membership =
true,
184 const Timeout & timeout = ZeroTimeout,
193 Spread::SP_disconnect(_mbox);
227 return _private_group;
237 return _group_membership;
248 _drop_receive = drop;
256 return _drop_receive;
265 void join(
const string & group) SSRC_DECL_THROW(
Error) {
266 int result = Spread::SP_join(_mbox, group.c_str());
278 int result = Spread::SP_leave(_mbox, group.c_str());
283 #ifdef LIBSSRCSPREAD_ENABLE_MAILBOX_KILL
295 Spread::SP_kill(_mbox);
321 int result = Spread::SP_poll(_mbox);
334 return _scatter.
add(data, size);
347 return _scatter.
add(message);
376 string group(
const unsigned int index)
const {
377 return _groups[index];
394 return _groups.
size();
419 int send(
const Message & message,
const string & group)
420 SSRC_DECL_THROW(
Error);
423 SSRC_DECL_THROW(
Error);
426 SSRC_DECL_THROW(
Error);
433 SSRC_DECL_THROW(
Error)
437 return send(message, _groups);
449 SSRC_DECL_THROW(
Error)
453 return send(_scatter, groups);
464 SSRC_DECL_THROW(
Error)
468 return send(_groups,
type, service);
479 SSRC_DECL_THROW(
Error)
481 return send(_groups,
type, service);
490 return send(message, _groups);
499 return send(message, _groups);
512 SSRC_DECL_THROW(BufferSizeError, Error)
514 clear_message_parts();
515 add_message_part(message);
516 return receive(_scatter, groups);
527 return receive(_scatter, groups);
538 return receive(message, _groups);
551 return receive(message, _groups);
562 return receive(_scatter, _groups);