dnsjit.core.thread(3)

dnsjit.core.thread3

Posix thread with separate lua state

Usage

local thr = require("dnsjit.core.thread").new()
thr:start(function(thr)
print("Hello from thread")
print("got:", thr:pop(), " = ", thr:pop(3))
end)
thr:push("value from main", 1, 2, 3)
thr:stop()

Overview

Start a new POSIX thread with it's own Lua state. Sharable objects can be passed to the thread by pushing and poping them of the thread stack. The Thread object and any other objects passed to the thread needs to be kept alive as long as the thread is running.

Functions

Thread.new()

Create a new Thread object.

Thread:log()

Return the Log object to control logging of this instance or module.

Thread:start(func)

Start the thread and execute the given function in a separate Lua state, first argument to the function will be the Thread object that created it. Returns 0 on success.

Thread:stop()

Wait for the thread to return. Returns 0 on success.

Thread:push(...)

Push string(s), number(s) or sharable object(s) onto the thread stack so they can be retrieved inside the thread using pop(). The sharable object(s) needs to be kept alive as long as the thread is running, strings and numbers are copied.

Thread:pop(num)

Pop value(s) off the thread stack, should only be called within the thread. If num is not given then one value is poped. Returns nil if no values are left on the stack.

AUTHORS and CONTRIBUTORS

Jerry Lundström (DNS-OARC), Tomáš Křížek (CZ.NIC), Petr Špaček (ISC)

Maintained by DNS-OARC

https://www.dns-oarc.net/

Releases

2 releases since Debian 12 (Bookworm); the text changed 1 time.

  1. 12
  2. 13

Bugs

For issues and feature requests please use:

https://github.com/DNS-OARC/dnsjit/issues

For question and help please use:

From dnsjit 1.5.0-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.