Instances of this class are each used to launch and control a thread.
pthreads :: Thread :: defaultinit
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
pthreads :: Thread :: defaultinit
core :: Finalizable :: defaultinit
core :: Object :: defaultinit
core :: Finalizable :: finalize
Liberate any resources held byself
before the memory holding self
is freed
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).app :: MyHttpRequest
Simple asynchronous HTTP request to http://example.com/ displaying feedback to the windowAsyncHttpRequest
where uri
is an attribute
# Handle to a thread
#
# Instances of this class are each used to launch and control a thread.
abstract class Thread
super Finalizable
# Type returned by `main`
type E : nullable Object
private var native: nullable NativePthread = null
# Is this thread finished ? True when main returned
var is_done = false
# Main method of this thread
#
# The returned valued is passed to the caller of `join`.
fun main: E do return null
private fun main_intern: E
do
# Register thread local data
sys.self_thread_key.set self
var r = main
self.is_done = true
return r
end
# Start executing this thread
#
# Will launch `main` on a different thread.
fun start
do
if native != null then return
native = new NativePthread.create(self)
end
# Join this thread to the calling thread
#
# Blocks until the method `main` returns or the target thread calls
# `Sys::thread_exit`. Returns the object returned from the other thread.
#
# Stats the thread if now already done by a call to `start`.
fun join: E
do
if native == null then start
var r = native.join
native = null
return r.as(E)
end
redef fun finalize
do
if native == null then return
native.free
native = null
end
end
lib/pthreads/pthreads.nit:300,1--357,3