Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CyanLight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fxk8y
CyanLight
Commits
9d871b4d
Commit
9d871b4d
authored
2 years ago
by
fxk8y
Browse files
Options
Downloads
Patches
Plain Diff
Adding fancy mutex manager
parent
9fa8c888
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CLC-qthing/SiliconTorch/NVSExplorer.hpp
+2
-2
2 additions, 2 deletions
CLC-qthing/SiliconTorch/NVSExplorer.hpp
CLC-qthing/SpiderLib/ManagedMutex.hpp
+51
-0
51 additions, 0 deletions
CLC-qthing/SpiderLib/ManagedMutex.hpp
with
53 additions
and
2 deletions
CLC-qthing/SiliconTorch/NVSExplorer.hpp
+
2
−
2
View file @
9d871b4d
...
...
@@ -14,7 +14,7 @@
// #include "driver/uart.h"
// project specific
//
#include ""
#include
"
SpiderLib/ManagedMutex.hpp
"
// qthing stuff
// #include <qthing>
...
...
@@ -56,7 +56,7 @@ namespace SiliconTorch {
NVSExplorer
();
SpiderLib
::
ManagedMutex
mutex
;
};
...
...
This diff is collapsed.
Click to expand it.
CLC-qthing/SpiderLib/ManagedMutex.hpp
0 → 100644
+
51
−
0
View file @
9d871b4d
#pragma once
// C++ system level
#include
<functional>
// ESP32 specific
#include
"esp_log.h"
#include
"FreeRTOS.h"
#include
"freertos/semphr.h"
// project specific
// #include <SpiderLib/Util.hpp>
namespace
SpiderLib
{
class
ManagedMutex
{
public:
ManagedMutex
()
{
semphr
=
xSemaphoreCreateBinary
();
if
(
semphr
==
NULL
)
{
ESP_LOGE
(
"ManagedMutex"
,
"Memory allocation FAILED"
);
abort
();
}
xSemaphoreGive
(
semphr
);
}
template
<
typename
T
>
T
run
(
std
::
function
<
T
()
>
body
)
{
// TODO: how infinitely is portMAX_DELAY really…?
while
(
xSemaphoreTake
(
semphr
,
portMAX_DELAY
)
==
pdFALSE
)
{};
T
result
=
body
();
xSemaphoreGive
(
semphr
);
return
result
;
}
private
:
SemaphoreHandle_t
semphr
;
};
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment