comparison src/luan/modules/http/tools/Java_threads.luan @ 1355:b84f60ebe196

minor fixes
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 17 Apr 2019 01:32:52 -0600
parents 8d95711f6615
children
comparison
equal deleted inserted replaced
1354:2449ca95dc1e 1355:b84f60ebe196
1 local Luan = require "luan:Luan.luan" 1 local Luan = require "luan:Luan.luan"
2 local error = Luan.error 2 local error = Luan.error
3 local Io = require "luan:Io.luan" 3 local Io = require "luan:Io.luan"
4 local Time = require "luan:Time.luan" 4 local Time = require "luan:Time.luan"
5 local Table = require "luan:Table.luan"
6 local to_table = Table.java_to_table_shallow or error()
5 local Http = require "luan:http/Http.luan" 7 local Http = require "luan:http/Http.luan"
6 require "java" 8 require "java"
7 local Thread = require "java:java.lang.Thread" 9 local Thread = require "java:java.lang.Thread"
8 10
9 11
12 function Java_threads.respond() 14 function Java_threads.respond()
13 Io.stdout = Http.response.text_writer() 15 Io.stdout = Http.response.text_writer()
14 16
15 local threads = Thread.getAllStackTraces() 17 local threads = Thread.getAllStackTraces()
16 local threads = {} 18 local threads = {}
17 for thread, trace in Luan.pairs(Thread.getAllStackTraces()) do 19 for thread, trace in Luan.pairs(to_table(Thread.getAllStackTraces())) do
18 threads[#threads+1] = { 20 threads[#threads+1] = {
19 trace = trace 21 trace = trace
20 string = thread.toString() 22 string = thread.toString()
21 state = thread.getState() 23 state = thread.getState()
22 } 24 }