Skip to content

Commit 5c83552

Browse files
authored
Feature/event manager subscriber task stack size (#94)
* feat(event_manager): allow setting subscriber task stack size * Updated add_subscriber method of EventManager to allow setting the subscriber task stack size (only sets the stack size when creating the task, which only happens on first subscriber for a given topic). * doc: rebuild
1 parent b1f8e3d commit 5c83552

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+167
-157
lines changed

components/event_manager/include/event_manager.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,15 @@ class EventManager {
7272
* @param component Name of the component publishing data.
7373
* @param callback The event_callback_fn to be called when receicing data on
7474
* \p topic.
75+
* @param stack_size_bytes The stack size in bytes to use for the subscriber
76+
* @note The stack size is only used if a subscriber is not already registered
77+
* for that topic. If a subscriber is already registered for that topic,
78+
* the stack size is ignored.
7579
* @return True if the subscriber was added, false if it was already
7680
* registered for that component.
7781
*/
7882
bool add_subscriber(const std::string &topic, const std::string &component,
79-
const event_callback_fn &callback);
83+
const event_callback_fn &callback, const size_t stack_size_bytes = 8 * 1024);
8084

8185
/**
8286
* @brief Publish \p data on \p topic.

components/event_manager/src/event_manager.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ bool EventManager::add_publisher(const std::string &topic, const std::string &co
1818
}
1919

2020
bool EventManager::add_subscriber(const std::string &topic, const std::string &component,
21-
const event_callback_fn &callback) {
21+
const event_callback_fn &callback,
22+
const size_t stack_size_bytes) {
2223
logger_.info("Adding subscriber '{}' to topic '{}'", component, topic);
2324
{
2425
std::lock_guard<std::recursive_mutex> lk(events_mutex_);
@@ -58,7 +59,7 @@ bool EventManager::add_subscriber(const std::string &topic, const std::string &c
5859
subscriber_tasks_[topic] = Task::make_unique(
5960
{.name = topic + " subscriber",
6061
.callback = std::bind(&EventManager::subscriber_task_fn, this, topic, _1, _2),
61-
.stack_size_bytes{8 * 1024}});
62+
.stack_size_bytes{stack_size_bytes}});
6263
// and start it
6364
subscriber_tasks_[topic]->start();
6465
}

docs/adc/adc_types.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
<li><a href="index.html">ADC APIs</a> &raquo;</li>
142142
<li>ADC Types</li>
143143
<li class="wy-breadcrumbs-aside">
144-
<a href="https://github.com/esp-cpp/espp/blob/24d75ce/docs/en/adc/adc_types.rst" class="fa fa-github"> Edit on GitHub</a>
144+
<a href="https://github.com/esp-cpp/espp/blob/7ab4637/docs/en/adc/adc_types.rst" class="fa fa-github"> Edit on GitHub</a>
145145
</li>
146146
</ul>
147147
<hr/>
@@ -158,7 +158,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
158158
<section id="header-file">
159159
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
160160
<ul class="simple">
161-
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/0c1c6a8/components/adc/include/adc_types.hpp">components/adc/include/adc_types.hpp</a></p></li>
161+
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/661fbc0/components/adc/include/adc_types.hpp">components/adc/include/adc_types.hpp</a></p></li>
162162
</ul>
163163
</section>
164164
</section>

docs/adc/ads1x15.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
<li><a href="index.html">ADC APIs</a> &raquo;</li>
143143
<li>ADS1x15 I2C ADC</li>
144144
<li class="wy-breadcrumbs-aside">
145-
<a href="https://github.com/esp-cpp/espp/blob/24d75ce/docs/en/adc/ads1x15.rst" class="fa fa-github"> Edit on GitHub</a>
145+
<a href="https://github.com/esp-cpp/espp/blob/7ab4637/docs/en/adc/ads1x15.rst" class="fa fa-github"> Edit on GitHub</a>
146146
</li>
147147
</ul>
148148
<hr/>
@@ -159,7 +159,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
159159
<section id="header-file">
160160
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
161161
<ul class="simple">
162-
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/24d75ce/components/ads1x15/include/ads1x15.hpp">components/ads1x15/include/ads1x15.hpp</a></p></li>
162+
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/7ab4637/components/ads1x15/include/ads1x15.hpp">components/ads1x15/include/ads1x15.hpp</a></p></li>
163163
</ul>
164164
</section>
165165
<section id="classes">

docs/adc/ads7138.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
<li><a href="index.html">ADC APIs</a> &raquo;</li>
143143
<li>ADS7138 I2C ADC</li>
144144
<li class="wy-breadcrumbs-aside">
145-
<a href="https://github.com/esp-cpp/espp/blob/24d75ce/docs/en/adc/ads7138.rst" class="fa fa-github"> Edit on GitHub</a>
145+
<a href="https://github.com/esp-cpp/espp/blob/7ab4637/docs/en/adc/ads7138.rst" class="fa fa-github"> Edit on GitHub</a>
146146
</li>
147147
</ul>
148148
<hr/>
@@ -164,7 +164,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
164164
<section id="header-file">
165165
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
166166
<ul class="simple">
167-
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/24d75ce/components/ads7138/include/ads7138.hpp">components/ads7138/include/ads7138.hpp</a></p></li>
167+
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/7ab4637/components/ads7138/include/ads7138.hpp">components/ads7138/include/ads7138.hpp</a></p></li>
168168
</ul>
169169
</section>
170170
<section id="classes">

docs/adc/continuous_adc.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
<li><a href="index.html">ADC APIs</a> &raquo;</li>
143143
<li>Continuous ADC</li>
144144
<li class="wy-breadcrumbs-aside">
145-
<a href="https://github.com/esp-cpp/espp/blob/24d75ce/docs/en/adc/continuous_adc.rst" class="fa fa-github"> Edit on GitHub</a>
145+
<a href="https://github.com/esp-cpp/espp/blob/7ab4637/docs/en/adc/continuous_adc.rst" class="fa fa-github"> Edit on GitHub</a>
146146
</li>
147147
</ul>
148148
<hr/>
@@ -164,7 +164,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
164164
<section id="header-file">
165165
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
166166
<ul class="simple">
167-
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/24d75ce/components/adc/include/continuous_adc.hpp">components/adc/include/continuous_adc.hpp</a></p></li>
167+
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/7ab4637/components/adc/include/continuous_adc.hpp">components/adc/include/continuous_adc.hpp</a></p></li>
168168
</ul>
169169
</section>
170170
<section id="classes">

docs/adc/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
<li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
135135
<li>ADC APIs</li>
136136
<li class="wy-breadcrumbs-aside">
137-
<a href="https://github.com/esp-cpp/espp/blob/24d75ce/docs/en/adc/index.rst" class="fa fa-github"> Edit on GitHub</a>
137+
<a href="https://github.com/esp-cpp/espp/blob/7ab4637/docs/en/adc/index.rst" class="fa fa-github"> Edit on GitHub</a>
138138
</li>
139139
</ul>
140140
<hr/>

docs/adc/oneshot_adc.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
<li><a href="index.html">ADC APIs</a> &raquo;</li>
143143
<li>Oneshot ADC</li>
144144
<li class="wy-breadcrumbs-aside">
145-
<a href="https://github.com/esp-cpp/espp/blob/24d75ce/docs/en/adc/oneshot_adc.rst" class="fa fa-github"> Edit on GitHub</a>
145+
<a href="https://github.com/esp-cpp/espp/blob/7ab4637/docs/en/adc/oneshot_adc.rst" class="fa fa-github"> Edit on GitHub</a>
146146
</li>
147147
</ul>
148148
<hr/>
@@ -163,7 +163,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
163163
<section id="header-file">
164164
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
165165
<ul class="simple">
166-
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/24d75ce/components/adc/include/oneshot_adc.hpp">components/adc/include/oneshot_adc.hpp</a></p></li>
166+
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/7ab4637/components/adc/include/oneshot_adc.hpp">components/adc/include/oneshot_adc.hpp</a></p></li>
167167
</ul>
168168
</section>
169169
<section id="classes">

docs/bldc/bldc_driver.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
<li><a href="index.html">BLDC APIs</a> &raquo;</li>
140140
<li>BLDC Driver</li>
141141
<li class="wy-breadcrumbs-aside">
142-
<a href="https://github.com/esp-cpp/espp/blob/24d75ce/docs/en/bldc/bldc_driver.rst" class="fa fa-github"> Edit on GitHub</a>
142+
<a href="https://github.com/esp-cpp/espp/blob/7ab4637/docs/en/bldc/bldc_driver.rst" class="fa fa-github"> Edit on GitHub</a>
143143
</li>
144144
</ul>
145145
<hr/>
@@ -156,7 +156,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
156156
<section id="header-file">
157157
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
158158
<ul class="simple">
159-
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/24d75ce/components/bldc_driver/include/bldc_driver.hpp">components/bldc_driver/include/bldc_driver.hpp</a></p></li>
159+
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/7ab4637/components/bldc_driver/include/bldc_driver.hpp">components/bldc_driver/include/bldc_driver.hpp</a></p></li>
160160
</ul>
161161
</section>
162162
<section id="classes">

docs/bldc/bldc_motor.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
<li><a href="index.html">BLDC APIs</a> &raquo;</li>
142142
<li>BLDC Motor</li>
143143
<li class="wy-breadcrumbs-aside">
144-
<a href="https://github.com/esp-cpp/espp/blob/24d75ce/docs/en/bldc/bldc_motor.rst" class="fa fa-github"> Edit on GitHub</a>
144+
<a href="https://github.com/esp-cpp/espp/blob/7ab4637/docs/en/bldc/bldc_motor.rst" class="fa fa-github"> Edit on GitHub</a>
145145
</li>
146146
</ul>
147147
<hr/>
@@ -172,7 +172,7 @@ <h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to
172172
<section id="header-file">
173173
<h3>Header File<a class="headerlink" href="#header-file" title="Permalink to this headline"></a></h3>
174174
<ul class="simple">
175-
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/24d75ce/components/bldc_motor/include/bldc_motor.hpp">components/bldc_motor/include/bldc_motor.hpp</a></p></li>
175+
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/7ab4637/components/bldc_motor/include/bldc_motor.hpp">components/bldc_motor/include/bldc_motor.hpp</a></p></li>
176176
</ul>
177177
</section>
178178
<section id="classes">
@@ -561,13 +561,13 @@ <h4>Example Usage<a class="headerlink" href="#classespp_1_1_bldc_motor_1bldc_mot
561561
<section id="id1">
562562
<h3>Header File<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h3>
563563
<ul class="simple">
564-
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/24d75ce/components/bldc_motor/include/bldc_types.hpp">components/bldc_motor/include/bldc_types.hpp</a></p></li>
564+
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/7ab4637/components/bldc_motor/include/bldc_types.hpp">components/bldc_motor/include/bldc_types.hpp</a></p></li>
565565
</ul>
566566
</section>
567567
<section id="id2">
568568
<h3>Header File<a class="headerlink" href="#id2" title="Permalink to this headline"></a></h3>
569569
<ul class="simple">
570-
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/24d75ce/components/bldc_motor/include/sensor_direction.hpp">components/bldc_motor/include/sensor_direction.hpp</a></p></li>
570+
<li><p><a class="reference external" href="https://github.com/esp-cpp/espp/blob/7ab4637/components/bldc_motor/include/sensor_direction.hpp">components/bldc_motor/include/sensor_direction.hpp</a></p></li>
571571
</ul>
572572
</section>
573573
</section>

0 commit comments

Comments
 (0)