Skip to content

Commit

Permalink
Add signalflow_msleep
Browse files Browse the repository at this point in the history
  • Loading branch information
ideoforms committed Oct 27, 2024
1 parent 44a3373 commit 397fcd6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions source/include/signalflow/core/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace signalflow
{
double signalflow_timestamp();
void signalflow_msleep(int millis);
long signalflow_create_random_seed();

double signalflow_clip(double value, double min, double max);
Expand Down
6 changes: 6 additions & 0 deletions source/src/core/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <thread>

namespace signalflow
{
Expand All @@ -28,6 +29,11 @@ double signalflow_timestamp()
/ 1000000.0;
}

void signalflow_msleep(int millis)
{
std::this_thread::sleep_for(std::chrono::milliseconds(millis));
}

long signalflow_create_random_seed()
{
/*--------------------------------------------------------------------*
Expand Down
4 changes: 2 additions & 2 deletions source/src/python/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void init_python_graph(py::module &m)
*-------------------------------------------------------------------------------*/
py::gil_scoped_release release;

std::this_thread::sleep_for(std::chrono::milliseconds(5));
signalflow_msleep(5);

if (graph.has_raised_audio_thread_error())
break;
Expand Down Expand Up @@ -188,7 +188,7 @@ void init_python_graph(py::module &m)
*-------------------------------------------------------------------------------*/
py::gil_scoped_release release;

std::this_thread::sleep_for(std::chrono::milliseconds(5));
signalflow_msleep(5);

if (graph.has_raised_audio_thread_error())
break;
Expand Down

0 comments on commit 397fcd6

Please sign in to comment.