<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
Hi,Ross,<br>
I'm doubting this piece of code works correctly. <br>
void BasicTaskScheduler0::triggerEvent(EventTriggerId
eventTriggerId, void* clientData) {<br>
// First, record the "clientData":<br>
if (eventTriggerId == fLastUsedTriggerMask) { // common-case
optimization:<br>
fTriggeredEventClientDatas[<b>eventTriggerId</b>] = clientData;
// here not use <b>fLastUsedTriggerNum</b>???<br>
}<br>
...<br>
}<br>
<br>
<!--WISESTAMP_SIG_21094_START--><!--WISESTAMP_SIG_21094_END-->于
2010-12-11 14:19, Ross Finlayson 写道:
<blockquote cite="mid:f06240802c928c1e29c45@%5B66.80.62.44%5D"
type="cite">One of the biggest problems that developers have had
with this library is that it has been difficult to define and
handle new kinds of event - beyond the file/socket I/O and delayed
task events that we support by default.
<br>
<br>
In particular, it has been difficult to implement input devices
(such as encoders) when we want to signal a new event (such as the
availability of new frame data) from an external thread. The
'watch variable' mechanism - although it can be used - is not
particular well-suited for this purpose. Furthermore, the model
code in "DeviceSource.cpp" has not been particular helpful,
because it doesn't really describe what to do to handle events
that are signaled from an external thread.
<br>
<br>
To overcome this, I have now installed a new version (2010.12.11)
of the "LIVE555 Streaming Media" library that now includes a new
'event trigger' mechanism for "TaskScheduler" (and its subclass,
"BasicTaskScheduler").
<br>
<br>
Specifically, you can now - using the new function
<br>
TaskScheduler::createEventTrigger()
<br>
- register an event handler function, to be associated with a
particular 'event trigger id'. At some later time, you can call
<br>
TaskScheduler:: triggerEvent()
<br>
with this 'event trigger id' as parameter, and this will cause the
event handler function to get called (from within the event loop).
<br>
<br>
For more details, see
"UsageEnvironment/include/UsageEnvironment.hh"
<br>
<br>
One nice feature of this mechanism is that - unlike other library
routines - the "triggerEvent()" function can be called from a
separate thread. This makes it easier to implement input device
classes.
<br>
<br>
<br>
I have also updated (and, I hope, significantly improved) the
model code in "liveMedia/DeviceSource.cpp". This code describes
how to implement an input device class that uses the new 'event
trigger' mechanism (with the event possibly being signaled from an
external thread).
<br>
<br>
If you're implementing (or have already implemented) an input
device class, then I encourage you to take a look at the new
"DeviceSource" code - and perhaps use this as a model for your
code.
<br>
</blockquote>
<br>
<br>
<div class="moz-signature">-- <br>
<b>P.J.</b></div>
</body>
</html>