Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
thread_spawn.c File Reference

Implements OP_THREAD_SPAWN to run a function in a background thread. More...

Go to the source code of this file.

Functions

 if (inst.operand==1)
 free_value (fnv)
 push_value (vm, make_int(tid))

Variables

case OP_THREAD_SPAWN
Value fnv = pop_value(vm)
int tid = fun_thread_spawn(fnv, argsMaybe, inst.operand == 1)
 break

Detailed Description

Implements OP_THREAD_SPAWN to run a function in a background thread.

Behavior:

  • Pops function and optionally one argument or an array of arguments (controlled by operand).
  • Spawns a new thread that invokes the function; pushes a thread id (int) or 0 on failure.

Errors:

  • If types are wrong or spawning fails, returns 0.

Definition in file thread_spawn.c.

Function Documentation

◆ free_value()

free_value(fnv)

◆ if()

if(inst.operand = =1)

Definition at line 25 of file thread_spawn.c.

◆ push_value()

push_value(vm,
make_int(tid) )

Variable Documentation

◆ break

break

Definition at line 33 of file thread_spawn.c.

◆ fnv

Value fnv = pop_value(vm)

Definition at line 28 of file thread_spawn.c.

◆ OP_THREAD_SPAWN

case OP_THREAD_SPAWN

Definition at line 22 of file thread_spawn.c.

◆ tid

int tid = fun_thread_spawn(fnv, argsMaybe, inst.operand == 1)

Definition at line 29 of file thread_spawn.c.