Jump to content




Is it possible to have two threads viewing events?


  • You cannot reply to this topic
2 replies to this topic

#1 thomasbogue

  • Members
  • 6 posts

Posted 10 August 2013 - 12:34 PM

Title: Is it possible to have two threads viewing events?
I'm building a GUI API, and I have an event processing loop. But I don't want to step on the toes of the user of my API by grabbing events that they were trying to process. I'd also like to be able to run my event processing loop in a separate thread. Right now I'm filtering pretty severely, but I might like to grab click, touch, and keypress events. Can I do this without preventing the user from having their own event processing loop?

#2 Bubba

    Use Code Tags!

  • Moderators
  • 1,142 posts
  • LocationRHIT

Posted 10 August 2013 - 12:41 PM

Well you could use os.queueEvent to queue any events that you filter out, but that would mean that you would have to get rid of the loop. ComputerCraft doesn't really have threads, but you can run things in parallel using either the parallel api or coroutines. However, both of these would require a bit of knowledge on the user's part. I personally just have a checkEvent function in your API that allows the user to check clicks and such whenever they want. This would be the easy solution.

#3 thomasbogue

  • Members
  • 6 posts

Posted 10 August 2013 - 02:43 PM

Thanks. That's much simpler than the ideas I had. Already written into the API.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users