Perl and C APIs

G

Gregski

I have an API which I wish to make accessible via Perl and I'm looking
for some advice:
Under C, I would normally set up sessions, register callbacks and then
run a control-loop API call which holds my program until the session
is broken; all processing of events is done solely through callbacks.

I'm having difficulty in getting to grips with how best to approach
this problem: if I purely tried to write a similar flow, I would never
be able to return a session handle to Perl, control would only return
once the API returned - useless because by then the session is broken.
On the other hand, if I register Perl functions for the callbacks from
C, I'm left with an un-Perl like program flow (yes, I know...),
because what *I think* I'd really like to do is use Perl to read data
in at polled intervals from the C-side called-back routines acting
effectively as data collectors. But do I?

One way round this would be to create a separate thread which enters
the control-loop, leaving another thread to do its stuff.

Additionally, since I want platform independence, I can't use fork.

1) What are my options?

2) Has anyone published a cookbook that deals with issues like these?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top