Skip to content

Commit b23d83c

Browse files
committedOct 20, 2014
kit::make_future, Circuit::sync(), Matrix::scale(), etc.
1 parent c7ed7c0 commit b23d83c

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed
 

‎include/kit/async/multiplexer.h

+7
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,13 @@ class Multiplexer:
256256
auto l = lock();
257257
return m_Units.empty();
258258
}
259+
void sync() {
260+
while(true){
261+
if(empty())
262+
return;
263+
boost::this_thread::yield();
264+
};
265+
}
259266
size_t buffered() const {
260267
auto l = lock();
261268
return m_Buffered;

‎include/kit/freq/animation.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,11 @@ class Animation:
291291
m_Frames.clear();
292292
}
293293
void finish(){
294-
process();
295294
if(!m_Frames.empty()) {
296-
m_Current = m_Frames.back().value();
295+
auto current = m_Frames.back().value();
296+
process();
297297
m_Frames.clear();
298+
m_Current = current;
298299
}
299300
}
300301
void stop(T position) {

‎include/kit/kit.h

+8
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,14 @@ namespace kit
607607
c.erase(std::remove(ENTIRE(c), o), c.end());
608608
}
609609

610+
template<class T, class ...Args>
611+
std::future<T> make_future(Args&&... args)
612+
{
613+
std::promise<T> tmp;
614+
tmp.set_value(std::forward<Args>(args)...);
615+
return tmp.get_future();
616+
}
617+
610618
template<class T, class... Args>
611619
std::unique_ptr<T> make_unique(Args&&... args)
612620
{

‎include/kit/math/matrixops.h

+8-3
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,16 @@ namespace Matrix {
101101
f[10]=v[2];
102102
f[15]=1.0f;
103103
}
104-
// assuming uniform scale
105-
inline float uniform_scale(glm::mat4& m) {
106-
float* f = glm::value_ptr(m);
104+
105+
inline float uniform_scale(const glm::mat4& m) {
106+
const float* f = glm::value_ptr(m);
107107
return f[0];
108108
}
109+
inline glm::vec3 scale(const glm::mat4& m) {
110+
const float* f = glm::value_ptr(m);
111+
return glm::vec3(f[0], f[5], f[10]);
112+
}
113+
109114
//inline float average_scale(glm::mat4& m) {
110115
// float* f = glm::value_ptr(m);
111116
// return (f[0] + f[5] + f[10]) / 3.0f;

0 commit comments

Comments
 (0)