Browse Source

removed blocking api

dmuratshin 9 years ago
parent
commit
4d43743c4a
3 changed files with 0 additions and 195 deletions
  1. 0 153
      oxygine/src/blocking.cpp
  2. 0 41
      oxygine/src/blocking.h
  3. 0 1
      oxygine/src/oxygine-framework.h

+ 0 - 153
oxygine/src/blocking.cpp

@@ -1,153 +0,0 @@
-#include "blocking.h"
-#include "Clock.h"
-#include "Tween.h"
-#include "Stage.h"
-
-#if _MSC_VER
-#define __func__ __FUNCTION__
-#endif
-
-namespace oxygine
-{
-    namespace blocking
-    {
-        std::list<coroutine::handle> blocked;
-
-        void schedule(coroutine::handle fiber)
-        {
-            blocked.push_back(fiber);
-        }
-
-        void resumeAll()
-        {
-            std::list<coroutine::handle> __blocked(blocked);
-            blocked.clear();
-            for (std::list<coroutine::handle>::iterator i = __blocked.begin(); i != __blocked.end(); ++i)
-            {
-                coroutine::handle y = *i;
-                coroutine::resume(y);
-                if (coroutine::isdead(y))
-                {
-                    coroutine::terminate(y);
-                }
-            }
-        }
-
-        int default_resume()
-        {
-            schedule(coroutine::current());
-            coroutine::resume();
-            return 0;
-        }
-
-        yieldCallback _mainLoopFunc = default_resume;
-        void setYieldCallback(yieldCallback f)
-        {
-            _mainLoopFunc = f;
-        }
-
-        int yield()
-        {
-            OX_ASSERT(_mainLoopFunc);
-#if OXYGINE_NO_YEILD
-            log::error("%s not supported", __func__);
-            return 0;
-#endif
-            return _mainLoopFunc();
-        }
-
-        void waitValue(bool& variable, bool value)
-        {
-#if OXYGINE_NO_YEILD
-            log::error("%s not supported", __func__);
-            return;
-#endif
-            while (variable != value)
-            {
-                yield();
-            }
-        }
-
-        void waitTween(spTween tween)
-        {
-#if OXYGINE_NO_YEILD
-            log::error("%s not supported", __func__);
-            return;
-#endif
-            if (tween->getDelay() == 0)//todo, workaround, fix assert for tweens with delay
-            {
-                OX_ASSERT(tween->isStarted());
-            }
-
-            while (!tween->isDone())
-            {
-                yield();
-            }
-        }
-
-        void waitTime(spClock clock, timeMS time)
-        {
-#if OXYGINE_NO_YEILD
-            log::error("%s not supported", __func__);
-            return;
-#endif
-
-            timeMS start = clock->getTime();
-            while (clock->getTime() - start < time)
-            {
-                yield();
-            }
-        }
-
-        void waitTime(timeMS time)
-        {
-#if OXYGINE_NO_YEILD
-            log::error("%s not supported", __func__);
-            return;
-#endif
-            timeMS start = getTimeMS();
-            while (getTimeMS() - start < time)
-            {
-                yield();
-            }
-        }
-
-
-        class clickWait
-        {
-        public:
-            bool _clicked;
-            timeMS _timeOut;
-
-            void click(Event* ev)
-            {
-                _clicked = true;
-            }
-
-            clickWait(spActor button, timeMS timeOut): _clicked(false), _timeOut(timeOut)
-            {
-                spClock clock = getStage()->getClock();
-                timeMS start = clock->getTime();
-                button->addEventListener(TouchEvent::CLICK, CLOSURE(this, &clickWait::click));
-                do
-                {
-                    yield();
-                    if (timeOut > 0 && (clock->getTime() - start > timeOut))
-                        break;
-                }
-                while (!_clicked);
-
-                button->removeEventListeners(this);
-            }
-        };
-
-        void waitClick(spActor button, timeMS timeOut)
-        {
-#if OXYGINE_NO_YEILD
-            log::error("%s not supported", __func__);
-            return;
-#endif
-            clickWait w(button, timeOut);
-        }
-    }
-}

+ 0 - 41
oxygine/src/blocking.h

@@ -1,41 +0,0 @@
-#pragma once
-#include "oxygine_include.h"
-#include "Actor.h"
-#include "core/coroutines.h"
-
-namespace oxygine
-{
-
-    DECLARE_SMART(Tween, spTween);
-    DECLARE_SMART(Clock, spClock);
-    DECLARE_SMART(Button, spButton);
-    namespace blocking
-    {
-        typedef int (*yieldCallback)();
-
-        /** optional
-            use default coroutines for yield or run your callback internally?
-        */
-#if !OXYGINE_NO_YEILD
-        void setYieldCallback(yieldCallback f);
-
-        /**
-            returns value from yieldCallback
-        */
-        int yield();
-
-        // schedule a coroutine to be resumed later
-        void schedule(coroutine::handle fiber);
-
-        // resume all scheduled coroutines
-        void resumeAll();
-
-        // wait for variable to become equal to value
-        void waitValue(bool& variable, bool value);
-        void waitTween(spTween);
-        void waitTime(spClock clock, timeMS time);
-        void waitTime(timeMS time);
-        void waitClick(spActor, timeMS timeOut = 0);
-#endif
-    }
-}

+ 0 - 1
oxygine/src/oxygine-framework.h

@@ -7,7 +7,6 @@
 #include "oxygine_include.h"
 #include "Actor.h"
 #include "AnimationFrame.h"
-#include "blocking.h"
 #include "Box9Sprite.h"
 #include "Button.h"
 #include "ClipRectActor.h"