# Introduction
I've always longed for a good, _fast_ way to relay information between
threads. So, I built one!
What's a message? It's anything you want it to be: a built-in data type, a
character string, a function pointer, or a complicated data structure. The
queue won't copy or move your structure, so internal pointers remain intact. A
message is anything your application wants to send between threads.
# How does it work?
The library uses a lock-free allocator to allocate memory for messages. Then,
your application can construct whatever it needs to send in-place. When you
write the message to the queue, it's added to a lock-free structure similar to
the one used to allocate memory.
# Why should I use this?
* It's fast. Crazy fast. My three-year-old laptop can push around 6,500,000
messages per second between threads, _including_ the overhead of allocating
the messages.
* It's easy. There are only 8 functions to learn, and you probably only need 6
of them. Really, there are only 3 concepts to worry about:
* initialization/teardown,
* allocation/deallocation, and
* writing/reading.
If you're a C programmer, you've dealt with all of these already.
# Why shouldn't I use this?
* It's new and so not widely tested. In fact, it's only been tested at all on
two x86_64 machines, running Mac OS X and Linux.
* It may be overly tuned to my Core 2 Duo. Performance is tricky and often
very hardware dependent. Hopefully wider exposure will help this work well
on a wider variety of hardware.
* I have no clue how well it scales past two CPUs. Anyone want to try it on a
bigger, beefier machine?
* You have to know how big the largest message you want to send on a given
queue is in advance, and you have to decide on a maximum depth the queue can
reach.
# How do I use this?
First, set up a message queue somewhere:
struct message_queue queue;
Before using it, you have to initialize it:
message_queue_init(&queue, 512, 128); /* The biggest message we'll send
* with this queue is 512 bytes, and
* the queue can only be 128
* messages deep */
To send a message:
struct my_message *message = message_queue_message_alloc_blocking(&queue);
/* Construct the message here */
message_queue_write(&queue, message);
Or, if you'd rather discard your message if there's no free memory in the
queue:
struct my_message *message = message_queue_message_alloc(&queue);
if(message) {
/* Construct the message here */
message_queue_write(&queue, message);
}
To read a message:
/* Blocks until a message is available */
struct my_message *message = message_queue_read(&queue);
/* Do something with the message here */
message_queue_message_free(&queue, message);
If you'd rather not block to wait for a new message:
/* Returns NULL if no message is available */
struct my_message *message = message_queue_tryread(&queue);
if(message) {
/* Do something with the message here */
message_queue_message_free(&queue, message);
}
Whenever you're done with the queue (and no other threads are accessing it
anymore):
message_queue_destroy(&queue);
So give it a shot and let me know what you think!
没有合适的资源?快使用搜索试试~ 我知道了~
STDF-Viewer-main.zip
共161个文件
png:33个
py:29个
c:27个
21 下载量 77 浏览量
2023-01-08
13:42:08
上传
评论
收藏 24.86MB ZIP 举报
温馨提示
STDF Viewer是一款用于分析半导体测试STDF报告的免费、高效的图形化界面程序。
资源推荐
资源详情
资源评论
收起资源包目录
STDF-Viewer-main.zip (161个子文件)
libvcruntime140.a 54KB
sqlite3_35_3.c 7.88MB
deflate.c 77KB
unzip.c 70KB
inflate.c 54KB
stdf4_func.c 48KB
bzlib.c 45KB
trees.c 43KB
blocksort.c 30KB
decompress.c 21KB
compress.c 20KB
gzread.c 20KB
gzwrite.c 19KB
gzlib.c 16KB
crc32.c 14KB
inftrees.c 13KB
inffast.c 13KB
ioapi.c 8KB
stdf4_io.c 8KB
hashmap.c 8KB
message_queue.c 7KB
zutil.c 7KB
huffman.c 7KB
adler32.c 5KB
crctable.c 5KB
randtable.c 4KB
testidmap.c 3KB
gzclose.c 678B
control 291B
COPYING 1KB
copyright 35KB
VCRUNTIME140.def 2KB
stdf-viewer.desktop 311B
.gitattributes 149B
.gitignore 1KB
.gitignore 685B
.gitignore 39B
sqlite3_35_3.h 571KB
zlib.h 94KB
crc32.h 30KB
stdf4_types.h 18KB
unzip.h 16KB
zconf.h 16KB
bzlib_private.h 13KB
deflate.h 13KB
trees.h 8KB
zutil.h 7KB
ioapi.h 7KB
gzguts.h 7KB
inflate.h 6KB
inffixed.h 6KB
bzlib.h 6KB
message_queue.h 6KB
inftrees.h 3KB
hashmap.h 2KB
stdf4_io.h 2KB
testidmap.h 2KB
stdf4_func.h 1KB
inffast.h 427B
stdfViewer_installer.icns 169KB
macos.icns 112KB
windows.ico 183KB
dmg.json 326B
LICENSE 34KB
LICENSE 2KB
Cargo.lock 24KB
README.md 3KB
linux.pickle 8KB
macos.pickle 6KB
windows.pickle 5KB
placeholder 0B
stdfViewer.png 327KB
trend interactive.png 302KB
test summary.png 258KB
failmarker.png 253KB
dut summary.png 244KB
dut summary read dut data.png 241KB
wafer.png 233KB
test summary read dut data.png 227KB
dut data table trans.png 217KB
bin.png 214KB
merge result.png 201KB
mainUI.png 188KB
trend interactive 2.png 186KB
report content selection.png 177KB
trend dynamic limit.png 157KB
wafer stacked.png 157KB
setting.png 150KB
wafer interactive.png 149KB
stdfViewer_installer.png 132KB
dut data table.png 131KB
wafer hide.png 123KB
debug panel.png 102KB
STDF-Viewer.png 100KB
merge panel.png 92KB
GDR DTR summary.png 89KB
report test selection.png 83KB
histo interactive.png 83KB
bin interactive.png 79KB
histo.png 77KB
共 161 条
- 1
- 2
资源评论
m0_72731342
- 粉丝: 2
- 资源: 1832
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功