3 * Copyright 2006 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include <mb_message.h>
29 static const int CACHE_LINE_SIZE = 64; // good guess
32 #if MB_MESSAGE_LOCAL_ALLOCATOR
34 static pmt_pool global_msg_pool(sizeof(mb_message), CACHE_LINE_SIZE);
37 mb_message::operator new(size_t size)
39 void *p = global_msg_pool.malloc();
41 // fprintf(stderr, "mb_message::new p = %p\n", p);
42 assert((reinterpret_cast<intptr_t>(p) & (CACHE_LINE_SIZE - 1)) == 0);
47 mb_message::operator delete(void *p, size_t size)
49 global_msg_pool.free(p);
56 mb_make_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority)
58 return mb_message_sptr(new mb_message(signal, data, metadata, priority));
61 mb_message::mb_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority)
62 : d_signal(signal), d_data(data), d_metadata(metadata), d_priority(priority),
67 mb_message::~mb_message()
73 operator<<(std::ostream& os, const mb_message &msg)
75 os << "<msg: signal=" << msg.signal()
76 << " port_id=" << msg.port_id()
77 << " data=" << msg.data()
78 << " metadata=" << msg.metadata()
79 << " pri=" << msg.priority()