removed unused methods(BeginPlay, Tick) and added rider plugin
This commit is contained in:
21
Plugins/Developer/RiderLink/Source/RD/thirdparty/countdownlatch/LICENSE
vendored
Normal file
21
Plugins/Developer/RiderLink/Source/RD/thirdparty/countdownlatch/LICENSE
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Nipun Talukdar
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
54
Plugins/Developer/RiderLink/Source/RD/thirdparty/countdownlatch/README.md
vendored
Normal file
54
Plugins/Developer/RiderLink/Source/RD/thirdparty/countdownlatch/README.md
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
CountdownLatch for C++ multi-threaded programming
|
||||
================================================
|
||||
|
||||
**CountdownLatch in C++**
|
||||
|
||||
-----------------------
|
||||
countdownlatch is a C++ library providing similar functionalities as availble with standard Java
|
||||
CountdownLatch class. It's main usage is: it allows one or more threads to wait until a set of
|
||||
operations being performed on other threads completes.
|
||||
|
||||
|
||||
**Below is an example regarding how to use the library**
|
||||
|
||||
---
|
||||
|
||||
```c++
|
||||
#include <unistd.h>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <countdownlatch.hpp>
|
||||
|
||||
void fun(clatch::countdownlatch *cl) {
|
||||
cl->await();
|
||||
std::cout << "Wait is over " << std::endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
auto cl = new clatch::countdownlatch(10);
|
||||
int i = 0;
|
||||
std::vector<std::thread*> ts;
|
||||
while (i++ < 2) {
|
||||
std::thread *t = new std::thread(fun, cl);
|
||||
ts.push_back(t);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i++ < 10) {
|
||||
sleep(1);
|
||||
cl->count_down();
|
||||
}
|
||||
i = 0;
|
||||
while (i < 2) {
|
||||
ts[i++]->join();
|
||||
}
|
||||
i = 0;
|
||||
while (i < 2) {
|
||||
delete ts[i++];
|
||||
}
|
||||
delete cl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
```
|
||||
34
Plugins/Developer/RiderLink/Source/RD/thirdparty/countdownlatch/countdownlatch.cpp
vendored
Normal file
34
Plugins/Developer/RiderLink/Source/RD/thirdparty/countdownlatch/countdownlatch.cpp
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <chrono>
|
||||
#include "countdownlatch.hpp"
|
||||
|
||||
clatch::countdownlatch::countdownlatch(uint32_t count) {
|
||||
this->count = count;
|
||||
}
|
||||
|
||||
void clatch::countdownlatch::await(uint64_t nanosecs) {
|
||||
std::unique_lock<std::mutex> lck(lock);
|
||||
if (0 == count){
|
||||
return;
|
||||
}
|
||||
if (nanosecs > 0) {
|
||||
cv.wait_for(lck, std::chrono::nanoseconds(nanosecs));
|
||||
} else {
|
||||
cv.wait(lck);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t clatch::countdownlatch::get_count() {
|
||||
std::unique_lock<std::mutex> lck(lock);
|
||||
return count;
|
||||
}
|
||||
|
||||
void clatch::countdownlatch::count_down() {
|
||||
std::unique_lock<std::mutex> lck(lock);
|
||||
if (0 == count) {
|
||||
return;
|
||||
}
|
||||
--count;
|
||||
if (0 == count) {
|
||||
cv.notify_all();
|
||||
}
|
||||
}
|
||||
51
Plugins/Developer/RiderLink/Source/RD/thirdparty/countdownlatch/countdownlatch.hpp
vendored
Normal file
51
Plugins/Developer/RiderLink/Source/RD/thirdparty/countdownlatch/countdownlatch.hpp
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef __COUNTDOWNLATCH_NIPUN__
|
||||
#define __COUNTDOWNLATCH_NIPUN__
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
|
||||
namespace clatch
|
||||
{
|
||||
class countdownlatch {
|
||||
public:
|
||||
/*! Constructor
|
||||
\param count, the value the countdownlatch object should be initialized with
|
||||
*/
|
||||
explicit countdownlatch(uint32_t count);
|
||||
|
||||
|
||||
/*!
|
||||
await causes the caller to wait until the latch is counted down to zero,
|
||||
if wait time nanosecs is not zero, then maximum wait is for nanosec nanoseconds
|
||||
\param nanosecs is waittime in nanoseconds, by default it is zero which specifies
|
||||
indefinite wait
|
||||
*/
|
||||
void await(uint64_t nanosecs=0);
|
||||
|
||||
/*!
|
||||
Countdown decrements the count of the latch, signalling all waiting thread if the
|
||||
count reaches zero.
|
||||
*/
|
||||
void count_down();
|
||||
|
||||
/*!
|
||||
get_count returns the current count
|
||||
*/
|
||||
uint32_t get_count();
|
||||
|
||||
private:
|
||||
std::condition_variable cv;
|
||||
std::mutex lock;
|
||||
uint32_t count;
|
||||
|
||||
// deleted constructors/assignmenet operators
|
||||
countdownlatch() = delete;
|
||||
countdownlatch(const countdownlatch& other) = delete;
|
||||
countdownlatch& operator=(const countdownlatch& opther) = delete;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user