Jerryscript::ContextList< ClassType > Class Template Reference

Manages a list of contexts. More...

#include <Context.h>

Inheritance diagram for Jerryscript::ContextList< ClassType >:
Collaboration diagram for Jerryscript::ContextList< ClassType >:

Public Types

using Callback = Delegate< void(ClassType &ctx)>
 
- Public Types inherited from LinkedObjectListTemplate< ObjectType >
using Iterator = typename LinkedObjectTemplate< ObjectType >::template IteratorTemplate< ObjectType, ObjectType *, ObjectType & >
 
using ConstIterator = typename LinkedObjectTemplate< ObjectType >::template IteratorTemplate< const ObjectType, const ObjectType *, const ObjectType & >
 

Public Member Functions

void foreach (Callback callback)
 Invoke callback once for each context via task queue. More...
 
- Public Member Functions inherited from OwnedLinkedObjectListTemplate< ClassType >
 OwnedLinkedObjectListTemplate ()=default
 
 OwnedLinkedObjectListTemplate (const OwnedLinkedObjectListTemplate &other)=delete
 
OwnedLinkedObjectListTemplateoperator= (const OwnedLinkedObjectListTemplate &other)=delete
 
 ~OwnedLinkedObjectListTemplate ()
 
bool remove (ClassType *object)
 
void clear ()
 
- Public Member Functions inherited from LinkedObjectListTemplate< ObjectType >
 LinkedObjectListTemplate ()=default
 
 LinkedObjectListTemplate (ObjectType *object)
 
ObjectType * head ()
 
const ObjectType * head () const
 
Iterator begin ()
 
Iterator end ()
 
ConstIterator begin () const
 
ConstIterator end () const
 
bool add (ObjectType *object)
 
bool add (const ObjectType *object)
 
bool insert (ObjectType *object)
 
bool insert (const ObjectType *object)
 
ObjectType * pop ()
 
size_t count () const
 
bool contains (const ObjectType &object) const
 
- Public Member Functions inherited from LinkedObjectList
 LinkedObjectList ()
 
 LinkedObjectList (LinkedObject *object)
 
bool add (LinkedObject *object)
 
bool add (const LinkedObject *object)
 
bool insert (LinkedObject *object)
 
bool insert (const LinkedObject *object)
 
bool remove (LinkedObject *object)
 
LinkedObjectpop ()
 
void clear ()
 
LinkedObjecthead ()
 
const LinkedObjecthead () const
 
bool isEmpty () const
 

Additional Inherited Members

- Protected Attributes inherited from LinkedObjectList
LinkedObjectmHead {nullptr}
 

Detailed Description

template<class ClassType>
class Jerryscript::ContextList< ClassType >

Manages a list of contexts.

Member Typedef Documentation

◆ Callback

template<class ClassType >
using Jerryscript::ContextList< ClassType >::Callback = Delegate<void(ClassType& ctx)>

Member Function Documentation

◆ foreach()

template<class ClassType >
void Jerryscript::ContextList< ClassType >::foreach ( Callback  callback)
inline

Invoke callback once for each context via task queue.

When calling into contexts we can do this:

...
String str = F("Some text");
int value = 12;
for(auto& ctx: contexts) {
ctx.customNotify(str, value);
}
#define F(string_literal)
Wrap a string literal stored in flash and access it using a String object.
Definition: WString.h:113
Manages a list of contexts.
Definition: Libraries/jerryscript/src/include/Jerryscript/Context.h:205
#define str(s)
Definition: testrunner.h:124

However, with many containers system responsiveness may be adversely affected. Instead, separate the calls out like this:

contexts.foreach([=](auto& ctx){
ctx.customNotify(str, value);
});

Note that all parameters are captured by copy (using [=]) as, for example, str will be destroyed when it goes out of scope.


The documentation for this class was generated from the following file: