lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

>From Sat Mar  7 06:20:30 1998
>Does anyone have experience using Lua in a multithreaded environment?  I 
>would like to run several low-priority threads simultaneously, each with 
>their own Lua script.  Is there anything in Lua that would break?  I don't 
>have any need for interprocess communication, just that nothing Lua-global 
>breaks.  Suggestions?

Some people have changed Lua to work in a multithreaded environment.
Lua 3.1 has support for multiple environments, with a single global variable
pointing to the current environment. This should help using Lua in 
a multithreaded environment.

>Second, is there some way to run a pre-compiled binary chunk directly from 
>memory rather than from a file?  I would like to link some pre-compiled 
>chunks directly into my executable, and then have Lua execute them. 
> Possible?

Lua 3.1 has an undocumented function lua_dobuffer that does this.
I think we'll make lua_dobuffer part of the official API when 3.1 is released.
Below, is a simple program that converts binary files to byte arrays that I
think will be useful to you.

>Lastly, is there an archive of the messages from this mailing list 
>somewhere?  I'd love to read the old traffic.

Everything is saved here but I don't know whether the list server is putting
out archives. Try sending 'help' to
If we cannot do this, I'll consider putting a link to it in the web pages.

* bin2c.c
* convert binary files to byte arrays
* Luiz Henrique de Figueiredo (
* 12 Jan 98 10:55:22

#include <stdio.h>

void dump(FILE* f, char* name)
 int n;
 printf("/* %s */\nstatic unsigned char B_",name);
 for (;*name; name++)
  if (isalnum(*name)) putchar(*name); else putchar('_');
 for (n=1;;n++)
  int c=getc(f); 
  if (c==EOF) break;
#if 0
  if (n==20) { putchar('\n'); n=0; }

void fdump(char* fn)
 FILE* f=fopen(fn,"rb");			/* must open in binary mode */
 if (f==NULL)
  fprintf(stderr,"bin2c: cannot open ");

void main(int argc, char* argv[])
 if (argc<2)
  while (--argc>0)