Can the lua – Can I know if it runs within the other?

Is there a way to let a function know whether it is running in a coroutine?

For example, I have a send_message() function that tries to send a message three times. It takes one second between each attempt. If this function is called from a coroutine, I want send_message The () function executes coroutine.yield() as part of its wait-1 second loop. But if it is not in the coroutine, then it should do a POSIX usleep().

Is there a way to do this a little?

I should look better in the Lua reference manual: coroutine.running() The thread call returns nil, which is perfect for this situation.

The original reason for asking was that I mixed coroutine.running() with coroutine.status().

See: http://www.lua.org/manual/5.1/manual.html#pdf-coroutine.running
and: http://www.lua.org/manual/5.1/manual. html#pdf-coroutine.status

Is there a way to let a function know whether it is running in a coroutine?

For example, I have a send_message() function that tries to send a message three times. It takes one second between each attempt. If this function is called from a coroutine, I want send_message The () function executes coroutine.yield() as part of its wait-1 second loop. But if it is not in the coroutine, then it should do a POSIX usleep().

Is there a way to do this a little?

I should look better in the Lua reference manual: coroutine.running() returns nil if called by the main thread, which is Perfect.

The original reason for asking was that I mixed coroutine.running() with coroutine.status().

See: http://www. lua.org/manual/5.1/manual.html#pdf-coroutine.running
and: http://www.lua.org/manual/5.1/manual.html#pdf-coroutine.status

< /p>

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3207 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.