views:

141

answers:

2

I should mention that i am using Mac OS X, XCode.

When a buffer has finished writing to file, it generates an event to tell the gui to read the data off the file.

I am not sure what kind of event would i need in this case? Is it possible to do it without using event?

Thank you.

A: 

It's possible without an event, but then you need to poll. Check out boost::asio. It's for networking, but I heard you can write to files and have it call a function for you when it's done. (asynchronously of course). There is also boost::signals2, that you can use with threads, when the write thread is done use the signal to call a "write is finished function". You can even use signals, with boost::bind to pass a file name or handle so you can display important information.

Chris H
This is incoherent and is only vaguely related to the question
Hassan Syed
A: 

Event handling in C++ primarily consists of exceptions and signals. The exact details of how these are handled is best described in the specification or one of Stroustrup's books.

Other event handling, such as mouse clicks, interrupts, and semaphores, is handled by the OS. Different OSes have different API and set up requirements for handling events. Many multi-thread and multi-tasking OSes allow a program to sleep until an event occurs (such as a setting a semaphore, generating a signal or sending a message).

You need to have your program, or thread, signal the GUI when finished writing to a file. Signal is defined by your OS or GUI framework.

FYI, in most designs, buffers don't write to files. Programs, tasks, or execution threads write buffers to files. Having a buffer write to a file may generate more signaling or context switching than having a thread write a buffer to a file.

Thomas Matthews