Mathieu Tozer's Dev Blog

Cocoa, the development of Words, and other software projects (including those dang assessment tasks).




Old Notes


E-mail this post



Remember me (?)



All personal information that you provide here will be governed by the Privacy Policy of Blogger.com. More...



I want words to define words in a separate thread, so that it doesn't
take control of the application
But I have to carefully design how this is going to happen?
At the word level?
At the word list level?

I think atomically at the word level it would be best.

I'd imaging that it would work something like this.

Define Word(s)
Start a new (worker?) thread
Pass the words to it
For each word
Start a progress indicator
When the word has been returned
Stop the progress indicator for that word.

Might the network connection monitor actually be better in another
thread too?
But that's not what takes all the time...
The application at any time needs to have connected dictionaries.
Should each dictionary have its own thread?
Or should the one thread manage all connected dictionaries.. or
should a connected dictionary itself be passed to the thread?
Or should a connected dictionary start a new thread for each stream
of words it needs to define?

So, when you ask a dictionary to define:words, it connects (if it
can) and starts a new thread to define the words. And quits when it's
done.

This model might make it easier because I don't have to change much
of the existing code base. But is it good form for a model object to
start a thread? Seems like a controller thing to do really.
But we do want each word to be able to be defining itself atomically
and independently of everything else.
And it would be nice to say "hey, you, try and define yourself!"
which could be done around a loop for each word, and it will go away
and create a thread for itself and look up everything in the right
dictionary etc.

For each word being defined
Start a new thread
Pass the define:word method to it
Kill the thread once the defining is done.

This could have too much overhead with starting and stopping all
those threads.

I kind of need to decide for certain though how I want the system to
define things.
Obviously I want it to try to define stuff for itself, but there also
has to be some way to force it to define words through the user
interface as well.

But this is the way it WILL work, if each dictionary has it's own
thread. So it's dictionary thread centric. A new dictionary thread is
started and is fed a word object which it takes. It does the work of
defining the word, and then defines the word (if it can), and let's
us know when it's done.

So by this, the define method in the dictionary should create the
thread.

I wonder if I start a thread at the point in the code that takes a
lot of time and makes the program freeze, that it will just work. The
new threads will follow along, and return back to the main thread
when the work is done, and just proceed like normal...


0 Responses to “Old Notes”

Leave a Reply

      Convert to boldConvert to italicConvert to link

 


+RSS | dev blog | Portfolio

About me

My status

Previous posts

  • my del.icio.us
  • my flickr