dnsjit.core.channel(3)
β¨ dnsjit.core.channel β¨
okay so bestie, this is a page from the dnsjit Library Functions Manual, and it's literally all about dnsjit.core.channel β the little cutie that sends data to another thread π
π NAME π
dnsjit.core.channel β send data to another thread, no cap π¦
πΈ SYNOPSIS πΈ
local chan = require("dnsjit.core.channel").new()
local thr = require("dnsjit.core.thread").new()
thr:start(function(thr)
local chan = thr:pop()
local obj = chan:get()
...
end)
thr:push(chan)
chan:put(...)
chan:close()
thr:stop()
π DESCRIPTION π
So like, a channel is the way you yeet data over to another thread π
and the way it does that is by putting a pointer to the data into a wait-free and lock-free ring buffer (that's concurrency kit, for the record). Iconic behaviour, honestly.
The channel runs on the single producer, single consumer model (SPSC), which means there can only be one writer and one reader. One. That's it. Don't get greedy π
π«Ά Attributes
int closedβ this is1if the channel has been closed. That's the whole vibe check. β¨
π§ Functions
Channel.new(capacity)β makes you a brand new Channel π the optionalcapacitysets the capacity of the channel (aka the buffer). Heads up:capacitymust be a power-of-two greater than or equal to 4. Default capacity is2048. Slay.Channel:log()β hands you back theLogobject so you can control logging for this instance or module πChannel:share()β returns the info you need when sharing this object between threads π―Channel:put(obj)β puts an object into the channel. If the channel is full it will stall and wait until space frees up π΄ and yes,objis allowed to benil.Channel:put(obj)β tries to put an object into the channel. Returns0on success. (yes bestie, the page really does listputtwice with the same signature β we're just reporting what it says, no edits π)Channel:get()β gets an object out of the channel. If the channel is empty it will wait until an object shows up β³ Returnsnilif the channel is closed, or if anilobject was explicitly put into the channel. Sneaky.Channel:try_get()β tries to get an object from the channel. Returnsnilif there were no objects to get. No waiting, no drama πChannel:size()β returns the number of enqueued objects π’Channel:full()β returnstruewhen the channel is full π΅Channel:close()β closes the channel. bye bye πChannel:receive()β returns the C functions and context for receiving objects βοΈChannel:receiver(o)β sets the receiver that objects get passed to. NOTE: the channel keeps no reference of the receiver, so it needs to live as long as the channel does β οΈ like, keep it alive or things get weird, fr fr.Channel:run()β retrieves all objects from the channel and sends them to the receiver πβοΈπ¨
π SEE ALSO π
dnsjit.core.thread(3)β go read this one too, iykyk π₯
π AUTHORS and CONTRIBUTORS π
The legends who made this happen:
- Jerry LundstrΓΆm (DNS-OARC)
- TomΓ‘Ε‘ KΕΓΕΎek (CZ.NIC)
- Petr Ε paΔek (ISC)
Maintained by DNS-OARC π«Ά
https://www.dns-oarc.net/
π BUGS π
Found a problem or want a new feature? Please use:
https://codeberg.org/DNS-OARC/dnsjit/issues
Got a question or need help? Please use:
admin@dns-oarc.net
okay that's the whole page bestie, and this lil manual moment came from dnsjit version 1.5.1, dnsjit.core.channel(3), dated way back on 1.5.1 β take care of yourself, hydrate, and may all your ring buffers be lock-free ππβ¨
π¦ where this page comes from
- epel 10: dnsjit 1.5.1-2.el10_2 Β· GPL-3.0-or-later
- epel 9: dnsjit 1.5.1-2.el9 Β· GPL-3.0-or-later
- fedora 43: dnsjit 1.5.1-2.fc43 Β· GPL-3.0-or-later
- fedora 43: dnsjit 1.5.1-2.fc43 Β· GPL-3.0-or-later
- fedora 44: dnsjit 1.5.1-2.fc44 Β· GPL-3.0-or-later
- fedora 44: dnsjit 1.5.1-2.fc44 Β· GPL-3.0-or-later
- ubuntu resolute: dnsjit 1.5.1-2 Β· GPL-3.0-or-later
- ubuntu stonking: dnsjit-dev 1.5.1-6 Β· GPL-3.0-or-later
- Copyright (c) 2018-2026 OARC, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms