>
>  What is the difference between an event and a callback function?  I
> think I understand how a callback works.  I thought an event caused a
> callback, but that doesn't look like what's happening here.

A callback is a function that is passed to some other routine, and called
from that routine later. In C, a callback would be a function pointer; in
Julia, a function may be passed either by name or anonymously (see the
docs). A typical example in a GUI application is to associate callback
functions with certain user actions (MouseOver, ButtonClicked, etc.).

The examples in the FTDI manual are "synchronous" (rather than
"asynchronous"), so there are no callbacks involved. In this context,
"event" refers to signalling of an OS-specific synchronization object:
EVENT_HANDLE and HANDLE on *nix and windows respectively (used with the
corresponding `pthread_cond_wait` and `WaitForSingleObject` functions). A
pointer to the sync object is passed as the third argument to
FT_SetEventNotification.
At some point, the appropriate wait function is called, it blocks until a
signal is raised on the synchronization handle, and then the wait function
returns and control flow resumes in the "reader". As indicated in the links
given earlier, it is necessary to run these blocking calls on a separate
async worker thread because the Julia event loop is not thread safe.

Also, beware that there are no guarantees on the timing of async completion
callbacks (due to other queued work, GC pauses blocking the event loop,
etc.).

On Sep 28, 2015 7:34 AM, "Chris Stook" <chris.st...@gmail.com> wrote:

> Thank you.
>>
>
> I have reviewed the suggested material.  I'm probably in way over my head
> with this, but I'd like to learn, so I'm going to ask what is probably a
> novice question.
>
> What is the difference between an event and a callback function?  I think
> I understand how a callback works.  I thought an event caused a callback,
> but that doesn't look like what's happening here.
>
> -Chris
>

Reply via email to