YOUR FEEDBACK
Werner Keil wrote: Java 6 update 10. If I'd be running Apple, I'd probably really drop dead...


2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
MXDJ TOP LINKS YOU MUST CLICK ON !


Get the most out of each of your CPU's ticks!
Multithread programming in Macromedia Director Xtras

Adding a message to the queue:

// Make sure that the queue did not reach its maximum size
// This call will block until the queue has some space available
WaitForSingleObject(mSemaphore, INFINITE);

// Request exclusive access to the queue
// This call will block if the queue is already being accessed elsewhere
EnterCriticalSection(&mCriticalSection);

// Add the event to the queue
mEventQueue.push(theEvent);

// Signal that we no longer require exclusive access
LeaveCriticalSection(&mCriticalSection);

Retrieving a message from the queue:

// Make sure that nobody else is accessing the queue
// This call will block if the queue is already being accessed elsewhere
EnterCriticalSection(&mCriticalSection);

// Pop the event
CEvent* event = 0;

if (!mEventQueue.empty()) // Check if the queue contains at least one item
{
   event = mEventQueue.front();
   mEventQueue.pop();
}

// Signal that we no longer require exclusive access
LeaveCriticalSection(&mCriticalSection);

// Release the Semaphore acquired during the push
// This call will eventually unblock a waiting push
ReleaseSemaphore(mSemaphore, 1, 0);

The Producer thread part is very simple. It will only call the message adding method shown above when it needs to communicate with the Consumer.

The Consumer thread will poll the queue manager on idle time and call Lingo every time it finds a message to process. It would do this with MOA's notification mechanism, more precisely through the IMoaNotificationClient interface. Briefly stated, your Xtra would register to this interface so it can be notified of events of type NID_DrNIdle (which are just plain idle events).

PIMoaNotificationClient pNotificationClient;
PIMoaNotification pMmNotification;
// Acquire MOA notification interface
pObj->pCallback->QueryInterface(&IID_IMoaNotification, (PPMoaVoid)
&This->pMmNotification);
if (pObj->pMmNotification != 0)
{
// Instantiate a notification client object
pObj->pCallback->MoaCreateInstance(&CLSID(CScript),
&IID(IMoaNotificationClient), (PPMoaVoid)&pObj->pNotificationClient);
if (pObj->pNotificationClient)
{
// Register the notification client object to receive IDLE events
pObj->pMmNotification->RegisterNotificationClient(pObj->
pNotificationClient, &NID_CustomNotificationID , 0, this);
}
}
The Notify function below is the core of the code
STDMETHODIMP CScript_IMoaNotificationClient::Notify
(ConstPMoaNotifyID nid, PMoaVoid pNData, PMoaVoid pRefCon)
{
/* variable declarations */
MoaError err = kMoaErr_NoErr;

// We ask the notification interface to pass a pointer to our CScript interface along
with the notification
CScript_IMoaMmXScript* pThis = (CScript_IMoaMmXScript*)pRefCon;

// Pop the event from the queue manager
CEvent* event = (CEvent*)pThis->pObj->pEventManager->PopEvent();

if (0 != event)
{
// Get the value of the counter pushed by the Producer
MoaLong tick;
event->GetEvent(tick);

// Call Lingo
MoaMmSymbol LingoHandlerSym;
MoaMmValue TickValue;

// Set the name of the Lingo handler to be called as a Symbol
pThis ->pObj->pMmUtils->StringToSymbol("ThreadSampleEvt", & LingoHandlerSym);

// Convert the counter vaue to a MoaValue
pThis ->pObj->pMmUtils->IntegerToValue(tick, & TickValue);

// Call the Lingo Handler
pThis ->pObj->pDrMovie->CallHandler(LingoHandlerSym, 1, & TickValue, 0);

// Release the MoaValue
pThis ->pObj->pMmUtils->ValueRelease(&TickValue);

// Free the memory used by the event
delete event;
}

return(err);
}

If you would like to see the complete script, it can be downloaded from: www.INM.com/services/xtras/sample/

About Laurent Brigaut
Laurent Brigaut - Director of Operations, Integration New Media (INM) Laurent has been the Director of Operations at Integration New Media (INM) for 5 years. During this time, he has developed and worked on several custom Xtras for clients and was the brainchild behind INM's SecureNet Xtra and Moka Xtra, two of INM's more specialized commercial Xtras. Laurent has an engineering degree in Computer Science from the Université de Technologie de Compiègne in France (equivalent to a Masters Degree) as well as twelve years experience in software R&D. Among the organizations he has worked for are CERN (European fundamental particles research center), FIRST (integrator and trainers of software for the disabled) and INM. Laurent is an expert in object based methods and technologies.

LATEST FLEX STORIES & POSTS
It's simple and minimalistic, has a small memory footprint and is easy on the CPU. Flash player works fine on my Windows XP box. JavaFX developers should like it too.
Alfresco Software announced that Adobe has implemented Alfresco’s document sharing and collaboration capabilities as part of the file sharing features in Acrobat.com. Adobe chose Alfresco as its content repository for its clustered high-availability, security, and highly capable tec...
Enterprises are enthusiastically embracing the shift from traditional client/server computing to SaaS. Inspired by customers who have embraced the Web, developers are using RIA tools to create innovative new on-demand business applications. One important factor in the shift from tradit...
Adobe Flex and Flash are the ideal technology for Rich Internet Applications because you can build those applications with reusable components that are Loosely Coupled. In his session, learn how you can create an On-Demand Authoring Environment for creating Rich Internet Applications b...
Director of Ribbit's Developer Platform, Chuck Freedman, will explore an evolution in web communication. With the growing demand of RIA and voice-over-the-web solutions, developers finally have a full suite of communication APIs to add to Flash. Coding with Ribbit, Freedman will demons...
Rich Internet Applications offer the potential to fundamentally change the user experience and in doing so, yield significant business benefits. The theme of this October's AJAXWorld Conference & Expo 2008 West is 'Beyond AJAX to the RIA Era' and the Call for Papers, which is still ope...
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE