That all depends. If you don't need to share data at all, BrowserUk's solution may be simplest. If you need to share data, it becomes a bit more of a mess. Coro allows you to go on without worrying about simultaneous access to shared resources - you only need semaphoring for when you want to keep someone from modifying something while your thread may be ceded (your thread "blocks" on some asynchronous access). And this should be pretty rare. With full-blown threads, it can get more complex in a hurry - the more complex the data that you need to share, the more thought you need to provide. Not that it can't be worth it, but weighing the options is probably prudent.
Update: "more thought you need to provide" includes things like semaphoring, not merely the act of sharing a hash. (Though I do wonder if the copying of the non-shared hash to the shared hash is atomic - is there a race condition there?)
In reply to Re^3: Coro, AnyEvent and performance
by Tanktalus
in thread Coro, AnyEvent and performance
by mcrose
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |