Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - How to wait for mme events in code?: (4 Items)
   
How to wait for mme events in code?  
Hi all,

I'm wondering how to best wait for MME events in my code using mme_get_event.
Is there a way to block until events are delivered or must I set up a timer as outlined in the MME Dev Guide in ch. 2? 
In the latter case, how to identify a suitable interval at which to trigger?

Best regards,
Thomas
Re: How to wait for mme events in code?  
> I'm wondering how to best wait for MME events in my code using mme_get_event.
> Is there a way to block until events are delivered or must I set up a timer as
>  outlined in the MME Dev Guide in ch. 2? In the latter case, how to identify a
>  suitable interval at which to trigger?

If you call mme_get_event() and there is no event waiting, you get a false event back with type MME_EVENT_NONE. You 
can't just block on the call.

The timer example is misleading, I don't think it is needed. If you talk about blocking, then you probably have a 
dedicated thread for event processing. In this case you can setup an event (say a pulse) and then  register that event 
with the MME. Then the thread can just enter a loop where it call mme_get_event() until MME_EVENT_NONE is returned, then
 the thread waits in MsgReceivePulse until it gets a pulse from the MME. Note that the thread should have a dedicated 
mme connection since you can't shared handle mme_connect() returns among threads. Or rather, you can share it, but you 
can't have two threads call into the MME at once using the same mme handle. 

Regards,
Gilles
Re: How to wait for mme events in code?  
Take a look at the mme_register_for_events( ) function which allows you to get notified when one or more events have 
been queued for you to recieve.  You can also look at mmecli.c for an example.
Re: How to wait for mme events in code?  
Thanks Gilles,

your proposal of using MsgReceivePulse to wait works.

@Dan: I already had that part correct, it was just how to make it behave blocking rather than a busy-loop :-)

Cheers,
Thomas