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

Cross-platform thread helpers and registry used by OP_THREAD_SPAWN/OP_THREAD_JOIN. More...

#include <stdint.h>
#include <time.h>
#include <pthread.h>
#include <unistd.h>
Include dependency graph for thread_common.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  FunThreadEntry
struct  FunTask

Macros

#define FUN_THREAD_CALL
#define FUN_MAX_THREADS   64

Typedefs

typedef pthread_t fun_thread_handle_t
typedef void * fun_thread_ret_t

Detailed Description

Cross-platform thread helpers and registry used by OP_THREAD_SPAWN/OP_THREAD_JOIN.

This file provides a tiny cross-platform threading layer (Windows/UNIX) embedded into the VM translation unit. It exposes utilities used by VM opcodes to spawn a function call in a background thread and later join it to retrieve the result.

Notes:

  • Thread registry is bounded by FUN_MAX_THREADS; not intended for high concurrency.
  • Each task owns its argument Values and transfers ownership of the result to the caller on successful join.

Definition in file thread_common.c.

Macro Definition Documentation

◆ FUN_MAX_THREADS

#define FUN_MAX_THREADS   64

Definition at line 51 of file thread_common.c.

◆ FUN_THREAD_CALL

#define FUN_THREAD_CALL

Definition at line 40 of file thread_common.c.

Typedef Documentation

◆ fun_thread_handle_t

typedef pthread_t fun_thread_handle_t

Definition at line 38 of file thread_common.c.

◆ fun_thread_ret_t

typedef void* fun_thread_ret_t

Definition at line 39 of file thread_common.c.