return (UDPC_HContext) ctx;
}
-void UDPC_enable_threaded_update(UDPC_HContext ctx) {
+int UDPC_enable_threaded_update(UDPC_HContext ctx) {
UDPC::Context *c = UDPC::verifyContext(ctx);
if(!c || c->flags.test(0) || c->thread.joinable()) {
- return;
+ return 0;
}
c->flags.set(0);
c->thread = std::thread(UDPC::threadedUpdate, c);
UDPC_CHECK_LOG(c, UDPC_LoggingType::UDPC_INFO, "Started threaded update");
+ return 1;
}
-void UDPC_enable_threaded_update_ms(UDPC_HContext ctx, int updateMS) {
+int UDPC_enable_threaded_update_ms(UDPC_HContext ctx, int updateMS) {
UDPC::Context *c = UDPC::verifyContext(ctx);
if(!c || c->flags.test(0) || c->thread.joinable()) {
- return;
+ return 0;
}
c->flags.set(0);
c->thread = std::thread(UDPC::threadedUpdate, c);
UDPC_CHECK_LOG(c, UDPC_LoggingType::UDPC_INFO, "Started threaded update");
+ return 1;
}
-void UDPC_disable_threaded_update(UDPC_HContext ctx) {
+int UDPC_disable_threaded_update(UDPC_HContext ctx) {
UDPC::Context *c = UDPC::verifyContext(ctx);
if(!c || !c->flags.test(0) || !c->thread.joinable()) {
- return;
+ return 0;
}
c->threadRunning.store(false);
c->flags.reset(0);
UDPC_CHECK_LOG(c, UDPC_LoggingType::UDPC_INFO, "Stopped threaded update");
+ return 1;
+}
+
+int UDPC_is_valid_context(UDPC_HContext ctx) {
+ return UDPC::verifyContext(ctx) != nullptr ? 1 : 0;
}
void UDPC_destroy(UDPC_HContext ctx) {
int updateMS,
int isUsingLibsodium);
-void UDPC_enable_threaded_update(UDPC_HContext ctx);
-void UDPC_enable_threaded_update_ms(UDPC_HContext ctx, int updateMS);
-void UDPC_disable_threaded_update(UDPC_HContext ctx);
+int UDPC_enable_threaded_update(UDPC_HContext ctx);
+int UDPC_enable_threaded_update_ms(UDPC_HContext ctx, int updateMS);
+int UDPC_disable_threaded_update(UDPC_HContext ctx);
+
+int UDPC_is_valid_context(UDPC_HContext ctx);
void UDPC_destroy(UDPC_HContext ctx);