Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "Headers/Task.h"

#include "Core/Headers/Console.h"
#include "Core/Headers/Application.h"
#include "Core/Headers/ApplicationTimer.h"
#include "Utility/Headers/Localization.h"

#include <chrono>
#include <thread>

namespace Divide {
    Task::Task(boost::threadpool::pool* tp, U64 tickInterval, I32 numberOfTicks, const DELEGATE_CBK<>& f) : GUIDWrapper(),
        _tp(tp),
        _tickInterval(tickInterval),
        _numberOfTicks(numberOfTicks),
        _callback(f),
        _end(false),
        _paused(false),
        _done(false)
    {
    }

    Task::~Task()
    {
        if (_end != true) {
            ERROR_FN(Locale::get("TASK_DELETE_ACTIVE"));
            stopTask();
        }
        while (!_done) {
        }
    }

    void Task::startTask(){
        DIVIDE_ASSERT(_tp != nullptr, "Task error: ThreadPool pointer is invalid!");
        if (!_tp->schedule(DELEGATE_BIND(&Task::run, this))) {
            ERROR_FN(Locale::get("TASK_SCHEDULE_FAIL"));
        }
    }

    void Task::stopTask(){
        _end = true;
    }

    void Task::pauseTask(bool state){
        _paused = state;
    }

    void Task::run(){
        D_PRINT_FN(Locale::get("TASK_START_THREAD"), std::this_thread::get_id());
        U64 lastCallTime = GETTIME();

        // 0 == run forever
        if (_numberOfTicks == 0){
            _numberOfTicks = -1;
        }

        _done = false;

        while (true) {
            if (_numberOfTicks == 0) {
                _end = true;
            }

            while ((_paused && !_end) || 
                   (Application::getInstance().mainLoopPaused() && 
                    !Application::getInstance().ShutdownRequested())) {
                continue;
            }
            if (_end || Application::getInstance().ShutdownRequested()) {
                break;
            }

            U64 nowTime = GETUSTIME(true);
            if (nowTime > (lastCallTime + _tickInterval)) {
                _callback();
                lastCallTime = GETUSTIME(true);
            }

            if (_numberOfTicks > 0) {
                _numberOfTicks--;
            }
        }

        D_PRINT_FN(Locale::get("TASK_DELETE_THREAD"), std::this_thread::get_id());

        _completionSignal(getGUID());
        _done = true;
    }
};

Commits for Divide-Framework/trunk/Source Code/Hardware/Platform/Task.cpp

Diff revisions: vs.
Revision Author Commited Message
331 Diff Diff IonutCava picture IonutCava Sat 06 Dec, 2014 20:53:45 +0000

[Ionut]
- Limited line length to 132 characters to improve readability and diff-comparisons
- Refactored memory allocation/deallocation functions
- Fixed a few compatibility issues with HashMap.h
- Fixed a bug in GPU Skinning shaders (cast a float to int)

330 Diff Diff IonutCava picture IonutCava Fri 10 Oct, 2014 17:19:11 +0000

[Ionut]
- New rendering algorithm :
— Perform second pass for visible nodes gathering all render commands and uploading them to an indirect draw buffer
— Render geometry with indirect draw commands
— Removed per-node range binding of the node buffer. Instead, bind the entire buffer once and index data in shaders
— Use “baseInstance” parameter from IndirectDrawCommand as a node buffer index
— Prefer DSA extensions for updating buffer data where applicable
- Moved all rendering specific code from SceneGraphNode to a new RenderingComponent
- Optimized “toString” utility function

326 Diff Diff IonutCava picture IonutCava Tue 30 Sep, 2014 21:11:32 +0000

[Ionut]
- Fixed more memory leaks
- Simplified Task interface and timing System
- Improved compatibility between Boost, STL and EASTL with random combinations of vectors, strings and maps
- Simplified Light class by removing the “slot” member
- Random optimizations

323 Diff Diff IonutCava picture IonutCava Thu 11 Sep, 2014 20:58:50 +0000

[Ionut]
- Reworked GFXDevice API initialization system
- Added a separate map for boolean values in ParamHandler
- More cleanups in GFXDevice class
- Fixed an infinite loop issue in Task class

322 Diff Diff IonutCava picture IonutCava Sat 06 Sep, 2014 20:33:47 +0000

[Ionut]
- Refactored most of Boost related code to be C++11 based
— Boost is only used for ThreadPool, Mutex handling, XML parsing and networking (ASIO)
— Function binds, threads, regex, NonCopyable base, Hashing algorithms and more are now using C++11 libraries
- Replaced all FOR_EACH calls with standard, range, “for” calls

318 Diff Diff IonutCava picture IonutCava Sat 30 Aug, 2014 17:35:53 +0000

[Ionut]
- Wrapped the entire code in a “Divide” namespace
- VertexBuffers now call “shrink_to_fit” on all internal data storage
- Improved some vector performance by preferring “emplace_back” instead of “push_back” + proepr usage of reserve / resize
- Wrapped OIS specific types and classes in Divide::Input namespace
- Added the messageBox.layout file (forgot it in the previous few commits)

316 Diff Diff IonutCava picture IonutCava Mon 25 Aug, 2014 22:04:03 +0000

[Ionut]
- Cleaned up AI classes
- Added basic Order <-> Goal system

314 Diff Diff IonutCava picture IonutCava Sun 24 Aug, 2014 19:54:33 +0000

[Ionut]
- More AI work
- Added some needed audio dlls

312 Diff Diff IonutCava picture IonutCava Fri 22 Aug, 2014 22:46:19 +0000

[Ionut]
- Replaced AESOP with CPPGOAP (https://github.com/cpowell/cppgoap)
- Added a better interface to GOAP classes and objects via the AISceneImpl
- Actions, goals and orders basic infrastructure

293 k1ngp1n picture k1ngp1n Tue 29 Jul, 2014 20:01:28 +0000

[Ionut]
- Code cleanup and comments in GLFWWrapper (for starters. more to follow)
- Reworked main loop logic (no more delegates and rendering api querying)
- Replaced all GLvoid with regular void
- replaced all boost::this_thread::sleep (deprecated calls) with boost::this_thread::sleep_for