A new user-data object can be returned by your downloadFile() or similarly named function for kicking off the thread. This new user-data object would contain the thread handle and have an associated meta-table with an index entry that would have a function for checking the completion status of the download, and contain other synchronization functions Possibly looking like this: local a = downloadFile("foo") -- do other things a:join() -- now let the download finish processFile() or this: local a = downloadFile("foo") local busywork = coroutine. Create(doOtherStuff) while(not a:finished()) do coroutine.
Resume(busywork) end processFile().
A new user-data object can be returned by your downloadFile() or similarly named function for kicking off the thread. This new user-data object would contain the thread handle and have an associated meta-table with an __index entry that would have a function for checking the completion status of the download, and contain other synchronization functions. Possibly looking like this: local a = downloadFile("foo") -- do other things a:join() -- now let the download finish processFile() or this: local a = downloadFile("foo") local busywork = coroutine.
Create(doOtherStuff) while(not a:finished()) do coroutine. Resume(busywork) end processFile().
You can't know WHEN you have to join() the two threads since you don't know when the user will input something. – Etan Dec 20 '09 at 16:27 1 join() is just an example of a possible synchronization call. Polling for download status would still be simple with a finished() type function.
– gwell Dec 22 '09 at 0:41.
Without integrating multithreading into lua ( which isn't that hard, Lua is already prepared for it ), your only solution is to handle the signaling in c++. From what you've said, there isn't any interaction with Lua in the thread downloadFile() creates, does Lua have to call processFile()? If not, what's stopping you from handling it all in c++?
If you need to notify Lua, you can always use a callback function ( save it in the registry ), handle the signal in c++ and run the callback. Since your engine is not thread-safe, I don't think there is a way to handle it in Lua.
Return a "future" object from the downloadFile function. This can be used to check the result of the long-running asynchronous operation. See java.util.concurrent.
Future or QFuture for example implementations. Also, check out this mailing list thread for a discussion of implementing futures/promises in Lua using coroutines.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.