Background processes in Neko

194 views
Skip to first unread message

David Peek

unread,
May 2, 2012, 4:45:43 PM5/2/12
to haxe...@googlegroups.com
Hi Nicolas,

Hopefully a simple one: is there a way to spawn a background process in Neko? Say, for example, a Haxe compilation server :)

Can't seem to find a way to detach from/not block the main process.

Thanks,
David

Cauê Waneck

unread,
May 2, 2012, 5:12:26 PM5/2/12
to haxe...@googlegroups.com
Hey David!

You can start a new Thread and call a new Process in there. If you need to use the result in your main thread, though, you might need to block anyway or have an event loop and use some kind of polling with e.g. neko.vm.Deque 

Cheers! ;)
Cauê

2012/5/2 David Peek <ninja...@gmail.com>

Nicolas Cannasse

unread,
May 2, 2012, 5:28:33 PM5/2/12
to haxe...@googlegroups.com
Le 02/05/2012 22:45, David Peek a �crit :
No you can't. I'm not sure which API is used for that BTW.

Best,
Nicolas

David Peek

unread,
May 2, 2012, 6:18:06 PM5/2/12
to haxe...@googlegroups.com
I don't know who to believe! ;)

I thought I had tried spawning the process in another thread, as that seems like the obvious solution. Will give that another go.

Thanks :)

Cauê Waneck

unread,
May 2, 2012, 8:24:45 PM5/2/12
to haxe...@googlegroups.com
Hey David!
I made a small demo of what I was talking about. See if it helps!


Cheers! :)
Cauê

2012/5/2 David Peek <ninja...@gmail.com>
I don't know who to believe! ;)

--

Cauê Waneck

unread,
May 2, 2012, 8:26:44 PM5/2/12
to haxe...@googlegroups.com
By the way, Nicolas, it would be great to have neko.vm.* mapped to sys.threading for Haxe 3.0 also ! : )

2012/5/2 Cauê Waneck <wan...@gmail.com>

Philippe Elsass

unread,
May 3, 2012, 5:54:38 AM5/3/12
to haxe...@googlegroups.com
Wow looks good - are there mutex & stuff? Is that hxcpp compatible?
--
Philippe

Cauê Waneck

unread,
May 3, 2012, 9:39:10 AM5/3/12
to haxe...@googlegroups.com

Wow looks good - are there mutex & stuff?

 
Is that hxcpp compatible?
 

Cauê

David Peek

unread,
May 9, 2012, 4:45:06 PM5/9/12
to haxe...@googlegroups.com
Hi Caue,

Thanks so much for the sample code, here's what I made with it in case it's on any use to anyone:

Basically a simple util for starting/stopping a haxe compilation server in a long running neko program (for the build tool I'm working on).

Cheers,
David


On Wednesday, May 2, 2012 9:45:43 PM UTC+1, David Peek wrote:

Cauê Waneck

unread,
May 9, 2012, 6:08:31 PM5/9/12
to haxe...@googlegroups.com
Hey David!

Thanks so much for the sample code, here's what I made with it in case it's on any use to anyone:

I'm happy I could have helped!
Just a small question, have you tried using Thread.readMessage with the block parameter as true? You wouldn't have to do the loop, if that doesn't interfere with the process :)

Cheers
Cauê
Reply all
Reply to author
Forward
0 new messages