|
|
@@ -4653,20 +4653,24 @@ const char *STD[][2] = {
|
|
|
" if type(fn) != \"function\"\n"
|
|
|
" throw TypeError(\"expected first argument to be: function, but got: \" + "
|
|
|
"type(fn))\n"
|
|
|
- " if type(args) != \"list\"\n"
|
|
|
- " throw TypeError(\"expected second argument to be: list, but got: \" + "
|
|
|
+ " if type(args) !in (\"list\", \"tuple\")\n"
|
|
|
+ " throw TypeError(\"expected second argument to be: list or tuple, but got: \" + "
|
|
|
"type(args))\n"
|
|
|
" inline `qi_value_t *args = qi_get(state, \"args\")`\n"
|
|
|
" inline `qi_list_t *list`\n"
|
|
|
- " inline `LOCKED(args, {list = qi_list_copy(args->value.list);})`\n"
|
|
|
+ " inline `if (args->type == QI_TUPLE) {`\n"
|
|
|
+ " inline ` list = args->value.list;`\n"
|
|
|
+ " inline `} else {`\n"
|
|
|
+ " inline ` LOCKED(args, {list = qi_list_copy(args->value.list);})`\n"
|
|
|
+ " inline `}`\n"
|
|
|
" inline `void *td = qi_thread_create(state, qi_get(state, \"fn\"), "
|
|
|
"list)`\n"
|
|
|
" inline `qi_decl(state, \"td\", qi_make_data(state, 'T', td))`\n"
|
|
|
" return Object({\n"
|
|
|
- " __str: func (this): \"<Thread>\",\n"
|
|
|
- " _td: td,\n"
|
|
|
- " joined: false,\n"
|
|
|
- " join: func (this) {\n"
|
|
|
+ " \"__str\": func (this): \"<Thread>\",\n"
|
|
|
+ " \"_td\": td,\n"
|
|
|
+ " \"joined\": false,\n"
|
|
|
+ " \"join\": func (this) {\n"
|
|
|
" if this.joined\n"
|
|
|
" return\n"
|
|
|
" var td = this._td\n"
|
|
|
@@ -4698,25 +4702,25 @@ const char *STD[][2] = {
|
|
|
" inline `if (!mutex) qi_throw_format(state, \"mutex init failed\")`\n"
|
|
|
" inline `qi_decl(state, \"mutex\", qi_make_data(state, 'M', mutex))`\n"
|
|
|
" return Object({\n"
|
|
|
- " __fin: func (this) {\n"
|
|
|
+ " \"__fin\": func (this) {\n"
|
|
|
" mutex = this._mutex\n"
|
|
|
" this._mutex = nil\n"
|
|
|
" inline `qi_mutex_destroy(qi_get_data(state, 'M', qi_get(state, "
|
|
|
"\"mutex\")))`\n"
|
|
|
" },\n"
|
|
|
- " __str: func (this): \"<Mutex>\",\n"
|
|
|
- " _mutex: mutex,\n"
|
|
|
- " lock: func (this) {\n"
|
|
|
+ " \"__str\": func (this): \"<Mutex>\",\n"
|
|
|
+ " \"_mutex\": mutex,\n"
|
|
|
+ " \"lock\": func (this) {\n"
|
|
|
" var mutex = this._mutex\n"
|
|
|
" inline `qi_mutex_lock(qi_get_data(state, 'M', qi_get(state, "
|
|
|
"\"mutex\")))`\n"
|
|
|
" },\n"
|
|
|
- " trylock: func (this) {\n"
|
|
|
+ " \"trylock\": func (this) {\n"
|
|
|
" var mutex = this._mutex\n"
|
|
|
" inline `return qi_make_boolean(state, "
|
|
|
"qi_mutex_trylock(qi_get_data(state, 'M', qi_get(state, \"mutex\"))))`\n"
|
|
|
" },\n"
|
|
|
- " unlock: func (this) {\n"
|
|
|
+ " \"unlock\": func (this) {\n"
|
|
|
" var mutex = this._mutex\n"
|
|
|
" inline `qi_mutex_unlock(qi_get_data(state, 'M', qi_get(state, "
|
|
|
"\"mutex\")))`\n"
|