Nol.A SDK Library  24.11.0
For IoT System Software Development
Classes
Protothread

Classes

class  Protothread
 Protothreads C++ implementation. More...
 

Initialization

#define PT_INIT()
 Initialize a protothread. More...
 

Declaration and definition

#define PT_BEGIN()
 Declare the start of a protothread inside the Protothread::run() function implementing the protothread. More...
 
#define PT_END()
 Declare the end of a protothread. More...
 

Blocked wait

#define PT_WAIT_UNTIL(condition)
 Block and wait until condition is true. More...
 
#define PT_WAIT_WHILE(cond)
 Block and wait while condition is true. More...
 

Hierarchical protothreads

#define PT_WAIT_THREAD(thread)
 Block and wait until a child protothread completes. More...
 
#define PT_SPAWN(thread)
 Spawn a child protothread and wait until it exits. More...
 

Exiting and restarting

#define PT_RESTART()
 Restart the protothread. More...
 
#define PT_EXIT()
 Exit the protothread. More...
 

Calling a protothread

#define PT_SCHEDULE(thread)
 Schedule a protothread. More...
 

Yielding from a protothread

#define PT_YIELD()
 Yield from the current protothread. More...
 
#define PT_YIELD_UNTIL(cond)
 Yield from the protothread until a condition occurs. More...
 

Detailed Description

Copyright (c) 2004-2005 Swedish Institute of Computer Science

Copyright (c) 2004-2005, Swedish Institute of Computer Science.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. Neither the name of the Institute nor the names of its contributors
   may be used to endorse or promote products derived from this software
   without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

Author: Adam Dunkels adam@.nosp@m.sics.nosp@m..se

Macro Definition Documentation

◆ PT_BEGIN

#define PT_BEGIN ( )

Declare the start of a protothread inside the Protothread::run() function implementing the protothread.

This macro is used to declare the starting point of a protothread. It should be placed at the start of the function in which the protothread runs. All C statements above the PT_BEGIN() invokation will be executed each time the protothread is scheduled.

Parameters
ptA pointer to the protothread control structure.

◆ PT_END

#define PT_END ( )

Declare the end of a protothread.

This macro is used for declaring that a protothread ends. It must always be used together with a matching PT_BEGIN() macro.

Parameters
ptA pointer to the protothread control structure.

◆ PT_EXIT

#define PT_EXIT ( )

Exit the protothread.

This macro causes the protothread to exit. If the protothread was spawned by another protothread, the parent protothread will become unblocked and can continue to run.

Parameters
ptA pointer to the protothread control structure.

◆ PT_INIT

#define PT_INIT ( )

Initialize a protothread.

Initializes a protothread. Initialization must be done prior to starting to execute the protothread.

Parameters
ptA pointer to the protothread control structure.
See also
PT_SPAWN()

◆ PT_RESTART

#define PT_RESTART ( )

Restart the protothread.

This macro will block and cause the running protothread to restart its execution at the place of the PT_BEGIN() call.

Parameters
ptA pointer to the protothread control structure.

◆ PT_SCHEDULE

#define PT_SCHEDULE (   thread)

Schedule a protothread.

This function shedules a protothread. The return value of the function is non-zero if the protothread is running or zero if the protothread has exited.

Parameters
threadPointer of the protothread to be scheduled

◆ PT_SPAWN

#define PT_SPAWN (   thread)

Spawn a child protothread and wait until it exits.

This macro spawns a child protothread and waits until it exits. The macro can only be used within a protothread.

Parameters
ptA pointer to the protothread control structure.
childA pointer to the child protothread's control structure.
threadThe child protothread with arguments

◆ PT_WAIT_THREAD

#define PT_WAIT_THREAD (   thread)

Block and wait until a child protothread completes.

This macro schedules a child protothread. The current protothread will block until the child protothread completes.

Note
The child protothread must be manually initialized with the PT_INIT() function before this function is used.
Parameters
ptA pointer to the protothread control structure.
threadThe child protothread with arguments
See also
PT_SPAWN()

◆ PT_WAIT_UNTIL

#define PT_WAIT_UNTIL (   condition)

Block and wait until condition is true.

This macro blocks the protothread until the specified condition is true.

Parameters
ptA pointer to the protothread control structure.
conditionThe condition.

◆ PT_WAIT_WHILE

#define PT_WAIT_WHILE (   cond)

Block and wait while condition is true.

This function blocks and waits while condition is true. See PT_WAIT_UNTIL().

Parameters
ptA pointer to the protothread control structure.
condThe condition.

◆ PT_YIELD

#define PT_YIELD ( )

Yield from the current protothread.

This function will yield the protothread, thereby allowing other processing to take place in the system.

◆ PT_YIELD_UNTIL

#define PT_YIELD_UNTIL (   cond)

Yield from the protothread until a condition occurs.

Parameters
condThe condition.

This function will yield the protothread, until the specified condition evaluates to true.