BriskVM threading?

BlitzMax Forums/BlitzMax Programming/BriskVM threading?

Blueapples(Posted 2008) [#1]
I'm trying to figure out if BriskVM supports threading, sort of like the way that the MicroC library does it, that is, something like this:


Thread = BVM_MakeThread(SourceFilename) ' Filename to compiled script, plain script, or a bank of bytecode

Repeat
  PollEvent()
  Select Case CurrentEvent.EventID
  .
  .
  .
  EndSelect
  BVM_TimeSlice(Thread, 100)
Forever


This would allow me to have BVM code interleaved and running "at the same time" as BM code, or anyway, allow me to process GUI events while running a BVM script.

I'm doing this with MicroC right now but honestly, and no offense to Helios, but it's a bit crufty code and not very many people are using it. I'd like to convert over to using BriskVM for our scripts.


plash(Posted 2008) [#2]
First, this would be better off in BriskVM forums.
Secondly, the only thing I know of that is on the lines with threads is tasks (and I'm pretty sure there isn't an example using them, yet): http://www.koriolis-fx.com/forum/index.php?topic=38.0 (#4)


Dreamora(Posted 2008) [#3]
or look for coroutines.


plash(Posted 2008) [#4]
BTW, did you get my emails?


Blueapples(Posted 2008) [#5]
Plash,

Nope. I was just wondering about that.


Koriolis(Posted 2008) [#6]
@BlueAppales: My plan for "threading" is to support it through two features:
- tasks, which are basically coroutines (syncronous, with explicit task switchs). The lastes release has a first implementation of this (this is not in the trial version yet)
- some kind of "processes", which will basically do what you ask for (based on timeouts). I'm currently working on this. In the meantime there is an "unoffically supported" way of doing this:
http://www.koriolis-fx.com/forum/index.php?topic=32.0


Blueapples(Posted 2008) [#7]
Koriolis,

The example in that thread looks perfect. Thanks! I'll look forward to it being a bit more "official" but for now this looks like it will accomplish my needs for the CE IDE and other projects.


Helios(Posted 2008) [#8]
Blueapples: lol, I don't blame you. Its pretty poor quality, as I have said on the download page. It was only ever made just as a brief attempt to see if I could make a scripting language. Its horribly slow, bloated and rather badly coded. I've done far better ones at other times, just haven't done any others in bmax recently. If I get a chance I'll rewrite a better version and release it.

Edit: Bit of a gravedig, sorry.


Blueapples(Posted 2008) [#9]
Helios,

I'm actually using MicroC for a pretty important project. The code is manageable and I can understand what's going on, which is important for this project. I guess it's the most basic implementation of a scripting language which could be useful, which isn't a bad thing.

I tend to think it isn't really that bloated at all. There are a few annoying bugs (like all scripts must have a final blank line or ParseBlock throws up) and I had to fix line reporting for errors (I believe the problem was a loop that eats whitespace up to the next token but did not increment TokenLine when eating newlines), but other than that it's not half bad.


Koriolis(Posted 2008) [#10]
I figured I should mention it here: Brisk v2.3 (released last week) now features "processes".
Replace "BVM_MakeThread" with "BVM_CreateProcess" and "BVM_TimeSlice" with "BVM_ExecProcesses", and you've got what you asked for.

http://www.koriolis-fx.com/forum/index.php?board=7.0

I'll probably start a new thread here when I release v2.4, as all the additions since v2.0 as a whole are worth being noticed.


Blueapples(Posted 2008) [#11]
Awesome! I'll grab the update right now, got to get back to the IDE scripting. This should make it a bit easier...