shithub: mc

ref: a8ab64015b9419f0a32c1162c2442c27163dff66
dir: /lib/thread/hookstd.myr/

View raw version
use std
use sys
use "mutex"
use "tls"

pkg thread =
;;

var memlck
var netlck
var envlck
var stdtls

const __init__ = {
	memlck = mkmtx()
	netlck = mkmtx()
	envlck = mkmtx()
	stdtls = tlsalloc()
	std.__lockinit( \
		(&memlck : void#), \
		(&netlck : void#), \
		(&envlck : void#), \
		{mtx; mtxlock((mtx : mutex#))}, \
		{mtx; mtxunlock((mtx : mutex#))}, \
		{; -> tlsget(stdtls)}, \
		{val; tlsset(stdtls, val)} \
	)
}