Skip to content

Commit 5e67613

Browse files
committed
Hiding clunky implementation details within neat CONNECT API.
1 parent 1250a32 commit 5e67613

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Diff for: examples/Threading_Basics/Source_Sink_Counter/Source_Sink_Counter.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
void setup()
77
{
8-
ProducerPrivate::counter.connectTo(ConsumerPrivate::counter);
8+
CONNECT(Producer, counter, Consumer, counter);
99
Producer.start();
1010
Consumer.start();
1111
}

Diff for: examples/Threading_Basics/Source_Sink_LED/Source_Sink_LED.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
void setup()
77
{
8-
Source_ThreadPrivate::led.connectTo(Sink_ThreadPrivate::led);
8+
CONNECT(Source_Thread, led, Sink_Thread, led);
99
Sink_Thread.start();
1010
Source_Thread.start();
1111
}

Diff for: src/Arduino_Threads.h

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ SinkBlocking<type> name{size}
7474
#define SINK_NON_BLOCKING(name, type) \
7575
SinkNonBlocking<type> name{}
7676

77+
#define CONNECT(source_thread, source_name, sink_thread, sink_name) \
78+
source_thread##Private::source_name.connectTo(sink_thread##Private::sink_name)
79+
7780
#define SHARED(name, type) \
7881
Shared<type> name
7982

0 commit comments

Comments
 (0)