From 3c08808f0e4acbbf89c6046cec5ef838af824676 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Tue, 26 Jul 2022 12:32:47 +0200 Subject: [PATCH 1/2] feat(naming) adds naming to sockets and threads for debugging also adds some debug functions to have a detailed view of yielding and resuming of threads in the scheduler. --- docs/index.html | 2 +- src/copas.lua | 247 +++++++++++++++++++++++++++++++++++++------- src/copas/queue.lua | 23 ++++- src/copas/timer.lua | 12 ++- 4 files changed, 240 insertions(+), 44 deletions(-) diff --git a/docs/index.html b/docs/index.html index 13d14f9..4ab01f1 100644 --- a/docs/index.html +++ b/docs/index.html @@ -109,7 +109,7 @@

History

Copas 3.0.0 [12/Nov/2021]
+
copas.getsocketname(skt)
+
Returns the name for the socket. +
+ +
copas.getthreadname([co])
+
Returns the name for the coroutine/thread. If not given defaults to the + currently running coroutine. +
+
func = copas.handler(connhandler [, sslparams])
Wraps the connhandler function. Returns a new function that wraps the client socket, and (if sslparams is provided) performs @@ -171,7 +194,8 @@

Copas dispatcher main functions

handlers. Every time a server accepts a connection, Copas calls the associated handler passing the client socket returned by socket.accept(). The init_func function is an - optional initialization function that runs as a Copas thread. + optional initialization function that runs as a Copas thread + (with name "copas_initializer"). The timeout parameter is optional, and is passed to the copas.step() function. The loop returns when copas.finished() == true. @@ -206,6 +230,15 @@

Copas dispatcher main functions

on how to deal with the arguments when implementing your own.
+
copas.setsocketname(name, skt)
+
Sets the name for the socket. +
+ +
copas.setthreadname(name [,co])
+
Sets the name for the coroutine/thread. co defaults to the + currently running coroutine. +
+
copas.wrap(skt [, sslparams] )
Wraps a LuaSocket socket and returns a Copas socket that implements LuaSocket's API but use Copas' methods like copas.send() and copas.receive() @@ -367,8 +400,19 @@

Non-blocking data exchange and timer/sleep functions

Returns list or nil + "destroyed".
-
queue.new()
-
Creates and returns a new queue. +
queue.name
+
A field set to name of the queue. See queue.new(). +
+ +
queue.new([options])
+
Creates and returns a new queue. The options table has the following + fields: +
queue:pop([timeout])
@@ -438,6 +482,8 @@

Non-blocking data exchange and timer/sleep functions

timer.new(options)
Creates and returns an (armed) timer object. The options table has the following fields;