How to override the event loop

As a windows game developer, I have always overridden the application message loop to make sure that graphics were rendered when the CPU was idle, and still being able to process windows messages like keyboard/mouse events. CPU is then maxed out (except when a forced sleep or v-sync is enabled) to give highest performance on graphics, making a simple clear opengl window render at 3500 frames per second (I know this is idiotic but I'm trying to make a point).
Now that I'm porting my game engine (c++ code) to cocoa, I  am struggling with how to implement the main loop. I could use a timer but this will fix the framerate and might be slow. It will prevent me to use the CPU to its full extent.
So: is there some kind of OnIdle event I can override? Or do I have to do the Event loop processing myself? And can anyone tell me how to do something like this? Is there a tutorial or a book or anything I can study to learn about this? I presume this is lower level API.
Any help is appreciated!
Dirk.

etresoft wrote:
Michael may profess ignorance about MacOS X applications, but he is still 100% correct. You need to study the architecture and find the best way to work with it. The first thing to know is that the CPU is irrelevant. Let the GPU handle your graphics - that is what it does best. You do want your CPU to be as idle as possible. Approach it from a device-driver or event-driven perspective.
Just to clarify that I'm not a total noob trying to write his first program: of course I will not overly use the CPU if not necessary. I completely agree with what you guys say about maximizing CPU usage. My game engine on windows will put the CPU to sleep when it's not necessary making my engine perform very good with almost no CPU usage.
But... when I want to test if changes to my engine/shaders/... improve or degrade performance of the renderings, I want to be sure that everything is maxed out so that I can be sure that the difference is correct. On maxed out CPU/GPU, I will notice the difference when framerate goes for example from 2000 to 1900 while this will not be visible when just at 60 fps and a lot of free time. I will see 60 fps even when my code is worse. That's why I need to be able to test this.
Anyway, as I said, I completely agree and I will certainly do my very best to make sure that CPU is not overly used. So my question remains: how can I make sure that I have everything I need at the time I need it while I will do my best to make sure nothing more is used?
Timer-events at 1/60th of a second is not the answer...
Using threads for these things is not the answer... I use them for other things (loading from disk/processing data/generating data)
But are there other options?
Can you point me to where I can learn more about the architecture and its possibilities?

Similar Messages

  • How do i include named event handlers in the event loop without using the optional preregister/postregister clause.

    The register statement in preregister/Postregister clause is especially useful for including named event handlers in the event loop.

    I think you need to read the doc. before asking the questions:
    http://docs.iplanet.com/docs/manuals/uds/50/toolref.pdf
    page 151-161
    ka

  • How to cancel the event in Item Adding and display javascript message and prevent the page from redirecting to the SharePoint Error Page?

    How to cancel the event in Item Adding without going to the SharePoint Error Page?
    Prevent duplicate item in a SharePoint List
    The following Event Handler code will prevent users from creating duplicate value in "Title" field.
    ItemAdding Event Handler
    public override void ItemAdding(SPItemEventProperties properties)
    base.ItemAdding(properties);
    if (properties.ListTitle.Equals("My List"))
    try
    using(SPSite thisSite = new SPSite(properties.WebUrl))
    SPWeb thisWeb = thisSite.OpenWeb();
    SPList list = thisWeb.Lists[properties.ListId];
    SPQuery query = new SPQuery();
    query.Query = @"<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>" + properties.AfterProperties["Title"] + "</Value></Eq></Where>";
    SPListItemCollection listItem = list.GetItems(query);
    if (listItem.Count > 0)
    properties.Cancel = true;
    properties.ErrorMessage = "Item with this Name already exists. Please create a unique Name.";
    catch (Exception ex)
    PortalLog.LogString("Error occured in event ItemAdding(SPItemEventProperties properties)() @ AAA.BBB.PreventDuplicateItem class. Exception Message:" + ex.Message.ToString());
    throw new SPException("An error occured while processing the My List Feature. Please contact your Portal Administrator");
    Feature.xml
    <?xml version="1.0" encoding="utf-8"?>
    <Feature Id="1c2100ca-bad5-41f5-9707-7bf4edc08383"
    Title="Prevents Duplicate Item"
    Description="Prevents duplicate Name in the "My List" List"
    Version="12.0.0.0"
    Hidden="FALSE"
    Scope="Web"
    DefaultResourceFile="core"
    xmlns="http://schemas.microsoft.com/sharepoint/">
    <ElementManifests>
    <ElementManifest Location="elements.xml"/>
    </ElementManifests>
    </Feature>
    Element.xml
    <?xml version="1.0" encoding="utf-8" ?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Receivers ListTemplateId="100">
    <Receiver>
    <Name>AddingEventHandler</Name>
    <Type>ItemAdding</Type>
    <SequenceNumber>10000</SequenceNumber>
    <Assembly>AAA.BBB, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8003cf0cbff32406</Assembly>
    <Class>AAA.BBB.PreventDuplicateItem</Class>
    <Data></Data>
    <Filter></Filter>
    </Receiver>
    </Receivers>
    </Elements>
    Below link explains adding the list events.
    http://www.dotnetspark.com/kb/1369-step-by-step-guide-to-list-events-handling.aspx
    Reference link:
    http://msdn.microsoft.com/en-us/library/ms437502(v=office.12).aspx
    http://msdn.microsoft.com/en-us/library/ff713710(v=office.12).aspx
    Amalaraja Fernando,
    SharePoint Architect
    Please Mark As Answer if my post solves your problem or Vote As Helpful if a post has been helpful for you. This post is provided "AS IS" with no warrenties and confers no rights.

    Recommended way for binding the list event handler to the list instance is through feature receivers.
    You need to create a feature file like the below sample
    <?xmlversion="1.0"encoding="utf-8"?>
    <Feature xmlns="http://schemas.microsoft.com/sharepoint/"
    Id="{20FF80BB-83D9-41bc-8FFA-E589067AF783}"
    Title="Installs MyFeatureReceiver"
    Description="Installs MyFeatureReceiver" Hidden="False" Version="1.0.0.0" Scope="Site"
    ReceiverClass="ClassLibrary1.MyFeatureReceiver"
    ReceiverAssembly="ClassLibrary1, Version=1.0.0.0, Culture=neutral,
    PublicKeyToken=6c5894e55cb0f391">
    </Feature>For registering/binding the list event handler to the list instance, use the below sample codeusing System;
    using Microsoft.SharePoint;
    namespace ClassLibrary1
        public class MyFeatureReceiver: SPFeatureReceiver
            public override void FeatureActivated(SPFeatureReceiverProperties properties)
                SPSite siteCollection = properties.Feature.Parent as SPSite;
                SPWeb site = siteCollection.AllWebs["Docs"];
                SPList list = site.Lists["MyList"];
                SPEventReceiverDefinition rd = list.EventReceivers.Add();
                rd.Name = "My Event Receiver";
                rd.Class = "ClassLibrary1.MyListEventReceiver1";
                rd.Assembly = "ClassLibrary1, Version=1.0.0.0, Culture=neutral,
                    PublicKeyToken=6c5894e55cb0f391";
                rd.Data = "My Event Receiver data";
                rd.Type = SPEventReceiverType.FieldAdding;
                rd.Update();
            public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
                SPSite sitecollection = properties.Feature.Parent as SPSite;
                SPWeb site = sitecollection.AllWebs["Docs"];
                SPList list = site.Lists["MyList"];
                foreach (SPEventReceiverDefinition rd in list.EventReceivers)
                    if (rd.Name == "My Event Receiver")
                        rd.Delete();
            public override void FeatureInstalled(SPFeatureReceiverProperties properties)
            public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
    }Reference link: http://msdn.microsoft.com/en-us/library/ff713710(v=office.12).aspxOther ways of registering the list event handlers to the List instance are through code, stsadm commands and content types.
    Amalaraja Fernando,
    SharePoint Architect
    Please Mark As Answer if my post solves your problem or Vote As Helpful if a post has been helpful for you. This post is provided "AS IS" with no warrenties and confers no rights.

  • How to create the event in the report for jobs scheduling.

    Hi Experts,
    i have a requirement like as follows:
    The following triggers for Batch Jobs in the SCM system will be created.i.     
    Background Processing Event = u201CAPO Background Processing Eventu201D. After sending the Event, write a Log Report line u201CEvent u201CAPO Background Processing Eventu201D sentu201D.
    Could you please suggest me how we create the Event or which transaction ?
    Please give me a steps for creating events so that based on these events we use
    CALL METHOD cl_batch_event=>raise
        EXPORTING
          i_eventid                      = p_bpeve
          i_server                       = p_server
          i_ignore_incorrect_server      = p_ignore
        EXCEPTIONS
          excpt_raise_failed             = 1
          excpt_server_accepts_no_events = 2
          excpt_raise_forbidden          = 3
          excpt_unknown_event            = 4
          excpt_no_authority             = 5
          OTHERS                         = 6.
    Right now i received message "APO Background Processing Event" is doesn't exists.
    Thanks in Advance.
    Puneet.

    Hi Puneet,
    Goto transaction SM62 and in there to BckProcEvents tab. There you can create the events.
    You just need to specify the name and Description of an event.
    Hope this serves your purpose.
    Thanks

  • How to avoid the event has been repeated many times in the background

    Application, the main screen is divided into two containers:left and  right container,
    The right side of the container is divided into two containers:top and  bottom container,
    There is a button in the left container.
    Click the button, the container at lower right will using ModuleManager  load Module,  The following container load of the right of the screen  has been monitoring the container above the action.
    Problem:
    When you click the button repeatedly to load the container in the lower  right, it will create multiple instances, and can not be freed  immediately. When the above container do an action or event, there are  multiple instances of monitoring exist.
    The background will be repeat the action or event many times.
    How to avoid the event has been repeated many times in the background?
    Thanks

    Flex harUI
    multiple instances of a mxml, maybe ?

  • How to capture the event in ALV grid display?

    Hi experts,
      How to capture the event in an ALV grid display which is editable. I have to capture the TAB key or ENTER key.
    regards,
    Arul Jothi.

    Hi Arul,
    Take a look at sample program BCALV_EDIT_03. (Find string "register ENTER" in the program to see how to register)
    Basically you have to Register edit events using method call REGISTER_EDIT_EVENT and then write a handler method for event DATA_CHANGED..
    If you are using a REUSE..GRID fm then first get the grid reference using function module GET_GLOBALS_FROM_SLVC_FULLSCR and then repeat the above procedure..
    Hope this helps..
    Sri
    Message was edited by: Srikanth Pinnamaneni

  • How to use the eventing and databag with a WAS 6.20 ?

    How to use the eventing and databag with a WAS 6.20 ?
    Is what there is a good guide for these services?
    Thank's

    In the raise event you can pass the value
    like below.
    <SCRIPT>
    function raiseEvt(value1){
    if(window.document.domain == window.location.hostname){
    if ( document.domain.indexOf(".") > 0 ) document.domain = document.domain.substr(document.domain.indexOf(".")+1);
       EPCMPROXY.raiseEvent( "urn:com.sap:BWEvents","BWiViewevent", value1, null );
      // alert('tree domain'+document.domain);
    </SCRIPT>
    and in the
    subscribe event you can get the values like below.
    <script language="javascript">
    if(window.document.domain == window.location.hostname){
    document.domain = document.domain.substring(document.domain.indexOf('.')+1);
        EPCMPROXY.subscribeEvent("urn:com.sap:BWEvents","BWiViewevent", window, "myreceiveEvent");
    function myreceiveEvent( eventObj ) {
          document.forms[0].gp_hidden.value = eventObj.dataObject;
    </script>
    Also look at the following link for a complete documentation.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/Enterprise%20Portal%20Client.pdf
    Regards
    Raja

  • HT4759 How can make the events listed in my chalenda become automatically a reminder in the reminder?:

    How can make the events listed in my chalenda become automatically a reminder in the reminder?:

    Welcome to the Apple community.
    Calendar and reminders are two different and separate apps, you cannot transfer information between the two of them.

  • How to override the default height of tree component...

    Hi,
    Can anyone please tell me how to override the default height of <af:tree> component.
    Actual Problem:
    I have a PanelBox in which I have a ShowDetail component. ShowDetail contains Tree component. When I click on ShowDetail item the Tree component have to be displayed. But, PanelBox is expanding to TREE default height(27.27 ems) instead of expanding to exact height of Tree.
    How to manage this issue?
    Thanks
    -Sukumar

    Did you already try
               <af:treeTable value="#{bindings.DashProjectPhasesDev.treeModel}"
                                  var="node"
                                  selectionListener="#{bindings.DashProjectPhasesDev.treeModel.makeCurrent}"
                                  rowSelection="none" rowBandingInterval="0"
                             inlineStyle="width:810px; height:1100px;"> Check the last line with inlineStyle...
    Julian

  • One of my kids changed my password, and now i can't access my mail accounts. Any ideas on how to override the password and set up a new one?

    one of my kids changed my password, and now i can't access my mail accounts. Any ideas on how to override the password and set up a new one?

    A mail account password or you login password?
    Which OS by the way?

  • How to remove the simulation loop from the block diagram

    hi,
    i have used lap view version 8.6 to design pid system. i have the pid block diagram with daq  on simulation loop. now my supervisor want me to remove the simulation loop. anyone know how to remove the simulation loop without deleting the pid block diagram. i have attached my pid program.
    Attachments:
    Copy of LAP VIEW FINAL for engine dyno.vi ‏221 KB

    logaraj wrote:
    hi,
    i have used lap view (  ) version 8.6 to design pid system. i have the pid block diagram with daq  on simulation loop. now my supervisor want me to remove the simulation loop. anyone know how to remove the simulation loop without deleting the pid block diagram. i have attached my pid program.
    You cannot remove the simulation loop alone because all the functions kept inside that loop will work inside that loop only. If you have to remove means then you have to find another way to inplement the PID control.
    The best solution is the one you find it by yourself

  • How to get the event before the session end?

    Currently i using a connection pool (dbpool). I need to release my pool when user logout or closing the browser. I have a session that keeping the user information and the connection pool manager.
    How i detect the event when session end? I need to know is that can catch an event and perform release() command before the session that store login information ended.
    Or have other solution to release the pool (it acually is only 1 pool, it will close the pool when no user(s) using it)

    you do not need to do this.
    In your db code, when you use
    conn.close(); your connection will be released to the pool.
    If you do not do this you will get connection pool leaks.
    There is no benefit in using a pool if you try and keep a connection for a single user, the idea is to SHARE connections between many users.
    If you want to detect session expiry yoyu need to use a 'session listener', if you search the forums you can easily find out how to do this.
    The main thng is NOT to tie your connections up in this way, you MUST use conn.close(); to release your connections back to the pool as soon as you have finished using them.

  • How to trap the event before unlock of locked text frames

    How to trap the event before the message "You must check out the contents of this frame in order to make changes. Check out now?" for locked text frames?
    I have tried installing the service Responder kUserEditTextCmdResponder
    The responder event is fired after the unlock of text frame in this case.
    I was trying the service kEditCmdPreProcessService, but I could not find the companion interface for this service.
    How to find the companion interface?

    calle111 wrote:
    The answer to why i need the event executed if nothing has changed is that in my application the text ring will hold some predefined settings for some other controls. If the user selects one of the predefined settings from the text ring a bunch of other controls will take predefined values. These values in the other controls can now be altered by the user. If the user now wants to re-apply the same set of pre-defined settings as last time it should be as simple as selecting the pre-defined settings from the text ring. If now the same value is selected from the text ring, no event will be executed.
    What you should do instead is change the value of the ring to a "special" value (e.g. using a local variable) whenever one of the other settings change, indicating that the settings have been modified. It seems wrong to show an inconsistent value in the ring, right?
    Now, whenever you change it back to one of the default settings, is IS a value changed event and there is no problem. .
    Here's a quick draft.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    event_testerMOD.vi ‏10 KB

  • How to override the onTouchUp in the user control which can be used to fire the event not only on this user control, but whole application

     I am a new to the C# and WPF. Right now, I want to override onTouchUp event in my user control. Then I can add user control in
    the references for reuse. The problem is each time I want to test this event on the application, the event only fire at area of user control, not whole screen. Anyone has solution for this?

    You cannot just add a UserControl to a window and expect its OnTouchUp method to get invoked when a TouchUp event occurs outside of the user control. That is not how routed events work.
    The OnTouchUp method of the UserControl will only be invoked when a TouchUp event occurs from within the UserControl.
    The event will indeed bubble up to the parent elements of the UserControl and you could for example handle the event in the parent window:
    <Window x:Class="WpfApplicationSlider.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525" TouchUp="Window_TouchUp">
    The OnTouchUp method of the UserControl will however never get invoked when you touch an element outside of the UserControl because an event only travels between the source element and the handler(s). This is how routed events work.
    If you want a "global" TouchUp event handler you should override the OnTouchUp of the top-level
    window:
    public partial class MainWindow : Window
    public MainWindow()
    InitializeComponent();
    protected override void OnTouchUp(TouchEventArgs e)
    base.OnTouchUp(e);
    //do your thing...
    If you want to be able to reuse the functionality across all of your windows in case you have several you could for example create an abstract window class and make all your windows inherit from this one:
    namespace WpfApplication1
    public abstract class BaseWindow : System.Windows.Window
    protected override void OnTouchUp(System.Windows.Input.TouchEventArgs e)
    base.OnTouchUp(e);
    //do your thing...
    MainWindow:
    public partial class MainWindow : BaseWindow
    public MainWindow()
    InitializeComponent();
    <local:BaseWindow x:Class="WpfApplicationSlider.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WpfApplication1"
    Title="MainWindow" Height="350" Width="525">
    </local:BaseWindow>
    Hope that helps.
    Please remember to mark helpful posts as answer to close your threads and please start a new thread if you have a new question.

  • How to EXIT the while loop in Event response section?

    I'm writing a program to grab image using a NI card. The application uses the Event structure. When the GRAB button was pressed, it snaps image continually by putting the SNAP function in a while loop. Is there some way to exit the while loop?(Note :The while loop was put in the GRAB IMAGE event response section.)

    edit this event-case AND uncheck "lock front panel until the event case for this event completes".
    BTW, your thanks should go to Ankita, <a href='http://forums.ni.com/ni/board/message?board.id=170&message.id=151282'>here</a>
    cheers! 
    Message Edited by Dynamik on 11-13-2005 01:26 AM
    Message Edited by Dynamik on 11-13-2005 01:38 AM
    When they give imbeciles handicap-parking, I won't have so far to walk!
    Attachments:
    untitled.GIF ‏20 KB

Maybe you are looking for

  • XML to database using OracleXML ...

    I am trying to insert xml file into CCX_persons table : I got the error message: C:\XML>java OracleXML putXML -user shrikant/akola@devdb -fileName xmlperson.xml "ccx_persons" oracle.xml.sql.OracleXMLSQLException: java.lang.ClassCastException: oracle.

  • CM12 upgrade from SP1 to R2 to CU4

    I am in the progress of upgrading SCCM 2012 to R2, we have successfully upgraded half the SP1 secondary sites to R2 Can we upgrade the primary now to CU4 while still having SP1 Secondary sites out there? Will I be able to upgrade SP1 secondary direct

  • MBP slow after Mavericks upgrade?

    Ever since installing Mavericks (or maybe it's unrelated, who knows) my MBP just seems sluggish. My impression is that the sluggishness is related to disk IO. I've thought about upgrading to an SSD since I know that would help, but I think it would j

  • How to send the PDF file to FAX will the nast table updates

    Hi all, How to send the PDF file to FAX. Will the nast table updates ( which fields updates ). Need is once fax is send for that delivery, again it should not fax again. Will the nast table helps to check the sent fax. Please give me sutable suggessi

  • Is there such a thing as "the easy way to access my Time Capsule"??

    Ok I'm totally new to Mac and I feel totally daft! I can't seem to figure out how to access my TimeCapsule from wherever I am in the world..... I read guides, I look at the manual but I am still totally lost! Can sameone please walk me through this,