eCap thread independent of transaction level

Asked by Jatin

Can I start an eCap thread which is independent of transactions but should know about all the current transactions. This should run all the time and should be able to send information to current active eCap transactions if any.

Is this possible? Can you please suggest how it can be done?

Question information

Language:
English Edit question
Status:
Solved
For:
eCAP Edit question
Assignee:
No assignee Edit question
Solved by:
Alex Rousskov
Solved:
Last query:
Last reply:
Revision history for this message
Alex Rousskov (rousskov) said :
#1

What you describe is possible. The only eCAP-specific concern here is that your code must not access or call any libecap::host objects from a thread other than the host thread.

Other than that, there is nothing eCAP-specific in your question so just use the usual thread-safety measures to protect the threads from destroying shared data or accessing destroyed data. How to do that is outside of eCAP scope, and the required API would depend on the threading library of your choice. Needless to say, writing thread-safe code is very difficult so avoid it if you can.

Revision history for this message
Jatin (jbhasin83) said :
#2

But how I can start this thread in first place? Because my host which is squid calls ecap only with a transaction. Do you think this is squid specific query ?

Revision history for this message
Best Alex Rousskov (rousskov) said :
#3

This feels more like a general programming question. There are many ways you may be able to start that "control" thread, including:

1. During the first call to libecap::adapter::Service's start() method, provided your host application calls that (it should!).
2. During the first call to libecap::adapter::Xaction's start() method.
3. Using C++ static initialization, just like the adapter service registration code (RegisterVersionedService) that you already use.

Revision history for this message
Jatin (jbhasin83) said :
#4

Thanks Alex Rousskov, that solved my question.