Text::Editor::Easy::Comm

Text::Editor::Easy::Comm is a thread communication mecanism of "Text::Editor::Easy" module.
Download

Text::Editor::Easy::Comm Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Sebastien Grommier
  • Publisher web site:
  • http://search.cpan.org/~grommier/Text-Editor-Easy-0.1/lib/Text/Editor/Easy/Comm.pm

Text::Editor::Easy::Comm Tags


Text::Editor::Easy::Comm Description

Text::Editor::Easy::Comm is a thread communication mecanism of "Text::Editor::Easy" module. Text::Editor::Easy::Comm is a thread communication mecanism of "Text::Editor::Easy" module.SYNOPSISThere are 2 (or 3 if we include the "Text::Editor::Easy::File_manager" module) complex modules in the "Text::Editor::Easy" tree. This module and the "Text::Editor::Easy::Abstract" which handles graphics in an encapsulated way.This module tries to make thread manipulation obvious with "Text::Editor::Easy" objects. Maybe this module could be adpated to be used with other objects to facilitate thread creation and use. This is not my goal : my goal is to write a generator of applications that can be modified dynamically (the Editor is the first part of that).There are 2 main classes of threads : server and client. A client thread is, for instance, your program that runs sequentially and, from time to time, ask a server thread for a service. A server thread is a waiting thread that manages a particular service. From time to time, it's called by a client (which can be a real client thread or another server thread : the calling server thread can be seen here as a client for our responding server), responds to the client and then waits again. Of course, if the server is saturated with calls, it won't wait and will execute all the calls in the order they have been made. So, the clients (real or other servers) may have to wait for the response of the server... but not always. Here come asynchronous calls : in an asynchronous call, the client asks for something to the server (gets, if it wants, an identification of the call, the "call_id"), and can go on without waiting for the response. But asynchronous calls are not always possible. Often, you have to make things in a certain order and be sure they have been made before going on. So most calls to server threads (by client) will be synchronous and blocking.Now that we have seen the 2 classes of threads let's talk more about server threads. There are mainly 3 types of server threads : owned by an instance (let's call it OWNED thread), shared by all the instances with separate data for all the instances (let's call it MULTIPLEXED thread), shared with all instances with no separate data (let's call it CLASS thread). All these types of threads haven't been invented for theorical beauty, but just because I needed them. The OWNED thread is the "File_manager" thread : each "Text::Editor::Easy" instance have a private one. The MULTIPLEXED thread is the graphic thread (number 0) : Tk is not multi-threaded, so I had to put private data in only one thread. All other threads that I use are CLASS threads : the thread model, number 1, that is only used to create new threads, the "Data" thread number 2, that shares common data such as "call_id" and asynchronous responses...The thread system allows me to create all the types of threads defined previously (OWNED, MULTIPLEXED, and CLASS) but it allows me more. First, there is no real limit between the 3 types of threads (I can have a thread with a MULTIPLEXED and CLASS personnality... or any other combination). Second, I'm able to define dynamic methods and have access to the code of all the methods to enable dynamic modifications. The demo8 of version 0.01 gave me ideas about what I needed to increase my productivity in developping my Editor.The "create_new_server" method can be called either with an instance, or with a class : my $tid = $editor->create_new_server ( {...} ); or my $tid = Text::Editor::Easy->create_new_server ( {...} );For an OWNED or MULTIPLEXED type, use the instance call. For the CLASS type use the class call. "create_new_server" uses a hash reference for parameters, and returns the "tid" ("thread identification" in the interpreted thread perl mecanism), which is an integer. This interface may be changed : just given to see actual capabilities. Of course, the more I use this interface to create all my threads, and the more I will be reluctant to change the interface. Requirements: · Perl


Text::Editor::Easy::Comm Related Software