multithreading in adobe flex - apache-flex

i want to know if i can use threading model like posix or any else in flex, i am a beginer of flex and i want to know if i can use threads in it for multitasking.

No, your Flash/Flex code will only run on a single thread, but you can achieve a lot through the asynchronous/event model.

Flex and ActionScript are single-threaded, so there's no threading model you can use.

http://cookbooks.adobe.com/post_Is_multi_threading_possible_in_Flash_or_ActionScri-12026.html
this is official from adobe

You can use the concept of Green Threads to provide multi threading in your Flex app.
Check this link for a sample implementation of Green Threads.
You would basically have to split your processing into chunks and use the main thread to run your thread along with your normal app.

Related

Qt for UI and Kotlin for application logic

I would like to use Kotlin for Linux desktop application. It does not have good UI library. I decided Qt would work well. So I though I would combine those two together. I do not want to use bindings library since there seams to not be any stable and maintained language binding. The way I would like to bind those two would be through use of ZeroMQ. I would like to have two way communication with application (UI needs to react to back end events too).
Has anyone tried such architecture or similar? Will there be any problem like validation or not being able to bind to the data. I would like to minimize use of C++, and use Kotlin for application logic, database, http communication with web server.
I am looking to build medium complexity embedded touch based interface (buttons, text fields, data rows).
Has anyone tried that? Is there a design error?
Communication between ZeroMQ and UI would resemble EventBus pattern.
Q : Has anyone tried such architecture or similar?
Yes.
Q : Is there a design error?
No.
Given you run for right-sized problem approach, the best production-grade results are expected from extending the industry-proved ( since adopted as early as in PARCplace Systems SmallTalk evangelisation in early 1980-ies... indeed some time to prove it be valid and best in class, isn't it? ) Model-Visual-Controller.
Have implemented the MVC-architecture-pattern in a shape and form of a distributed-system, integrated atop the smart ZeroMQ communcation infrastructure. Remote-keyboard was one of remote'd C-controller-inputs (with a dumb CLI V-isual ), another host ( supported by a computing grid ) did consolidate and operate the global M-odel and all the MVC-state transitions, next using another remote V-isual platform, for GUI and some other MMI-interactions, recollected from there back, into the central M-odel part.
Indeed a lovely way to design whatever complex systems!
It was robust, smart, scalable and maintainable architecture and would but recommend to follow this path forwards.

Using pyglet, twisted, pygtk together in an application

I am making an app, that lets you play music synchronously on different systems. For the project, I have decided to use twisted, PyGtk2, Pyglet. I am confused on how should the main loop be run. Should i run pyglet's loop in a separate thread or should i implement a new reactor integrating twisted, pygtk2, pyglet. Will the performance suffer if i try to integrate three loops together?
I used https://github.com/padraigkitterick/pyglet-twisted when playing with pyglet and twisted, and it worked for my toy cases. Good starting point, anyway.
The above is a new reactor based on ThreadedSelectReactor.
It's not clear to me what the composition of all three would look like...
Twisted already has a solution for integrating with gtk:
http://twistedmatrix.com/documents/current/core/howto/choosing-reactor.html#core-howto-choosing-reactor-gtk
I'm not familiar with pyglet but if it has a main loop like GTK then both of your ideas seem feasible. You could also look into how twisted implements the GTK integration explained in the link above and try to replicate that for pyglet.

Benchmark application for Qt?

I would like to do some profiling and benchmarking of Qt. The purpose of the profiling and benchmarking is to get the better understanding of Qt, and see what functions take most of the time, where are typical bottlenecks, is it rendering or some event processing, etc.
Can anybody suggest me what application to use for the benchmark? Are there any sample benchmarking applications that exploit Qt GUI? Is there anything like that that comes with the SDK?
The SDK comes with a bunch of examples and demo programs. The demo programs cover all the major aspects of Qt. You could use that to benchmark each of them pretty simply.
Going with larger apps (like KDE, or QtCreator itself maybe) is going to be much harder because of the complexity of the code and amount of non-Qt stuff (for KDE).
valgrind http://valgrind.org/ is a powerful profiler

How to check the performance & memory usage of the flash application at run time?

I have a flash application which consist of Grid Components, Button, Label, and Combo-box Components. All these components are used more than 70 times(simultaneously) with in the application. So Its takes too much of memory. So How can I test the memory usage of each component at the time of running. Is there any plug-in available for browsers to find the memory usage.
I'm using flash CS3 and ActionScript 3.0. The application suppose to run in browsers.
I think MonsterDebugger will help you. Besides memory and FPS monitor, it has lots of other useful features.
You can also try FlashPreloadProfiler to monitor memory and DisplayObjects lifecycle.
If you're using Abobe Flash Builder, you can use its built in profiler.
Adobe Flash Builder 4 * Profiling Flex applications
For a simple performance stats display, check out Mr. Doob's Stats class.
For a more in-depth look into your application's performance, there is FlashPreloadProfiler.
Check this info:
http://www.flashandmath.com/howtos/memory/
Memory consumption:
import flash.system.System;
function performMemTest(e:Event):void {
trace(System.totalMemory);
}
About Frame Rate you can check by link.

QTextEdit.insertHtml() is very slow

I've given up on actually trying to make it go faster.
My biggest problem is that when I'm inserting the html, the application slows down to a crawl.
I have a progressbar, and I'm calling
QCoreApplication.processEvents()
(I'm using pyqt, by the way)
Can I put insertHtml() into a different thread, so I don't have an unresponsive interface?
How would I go about that? I've looked into QThread and QThreadPool, and I'm not quite sure where to begin.
I had this problem as well, here are a few things I did to make it faster:
TxtBrows->setAcceptRichText(false);
TxtBrows->setContextMenuPolicy(Qt::NoContextMenu);
TxtBrows->setOpenLinks(false);
TxtBrows->setReadOnly(true);
TxtBrows->setUndoRedoEnabled(false);
This should get rid of unneeded overhead.
Also when inserting large amounts of text its good to turn off screen updates:
setUpdatesEnabled(false);
TxtBrows->append(SomeBigHTMLString);
setUpdatesEnabled(true);
This was recommended somewhere in the Qt documentation but I can't find the spot just now.
[Edit]
I stumbled across the spot in the Docs (just in time for them to be outdated by QT5 grinn) http://qt-project.org/doc/qt-4.8/qwidget.html#updatesEnabled-prop
In GUI applications, the main thread
is also called the GUI thread because
it's the only thread that is allowed
to perform GUI-related operations.
-- from the Qt Docs
So, no. Unfortunately you cannot perform that operation in a thread.
Edit: Technically, it is possible. I just wrote a short snippet that did so, however using Qt GUI objects in that way is highly unsafe.

Resources