Wait on Event due to database update
i am using a MYSQL database as form of IPC datastore between web client and C code process on Debian linux. When web client writes some data to the mysql database via php script, i need my C code app to go and pickup that data.
However i don't want the C app continually polling some flag to chec开发者_开发知识库k if data is available. Is there anyway it a thread can wait on some event from a mysql database or something that when signalled will allow it to unblock and process the data
Thanks
What you are trying to do is a little cumbersome, but it can work.
All you need to make it work is to use a trigger that will fire when data is inserted in the database.
The trigger
will call a user-defined function (UDF) that in turn will signal your C
code to start processing the newly inserted data.
You don't even need to write your own UDF
. You can use sys_exec from the lib_mysqludf_sys library to execute an external program.
please provide whole scenario . What I guess is that you can use EVENTS in combination with a table (for flags ) to achieve this kind of functionality. I am working on similar problem. If you could provided a detail description it might be helpful. In my case I have trigger which set a flag on certain records in same table to update , and enables event scheduler , then an event updates flagged records and disables event scheduler .
精彩评论