• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Doc
  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Products
    • Automation Designer
    • HMI Designer
    • Maritime HMIs
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Framework - CDP Core
  • CrossThreadValueNode
  • 5.0.0

CrossThreadValueNode Class

(CDP::StudioAPI::CrossThreadValueNode)

A class for the cross-thread manipulatable value. Can be used in situations where a value needs to be manipulated (read and/or written) from a thread context. The shadow value of the node is created in the thread context and can be manipulated there. An addition, a thread context value copy is created for direct manipulation in the thread context and to determine if the thread context value has been changed and the change should be synced back to the node context. All value synchronization between the threads is done without mutexes - only using lockfree commands queues. More...

Header: #include <CrossThreadValueNode>
  • List of all members, including inherited members

Public Functions

CrossThreadValueNode(ICDPNode *node, RunInThreadQueue *threadContextRunQueue, const std::function<void( CrossThreadValueNodeBase * pointerToMe ) > &onNodeRemove = {})
~CrossThreadValueNode() override
T &GetThreadContextValueRef()

Reimplemented Public Functions

virtual void AddSyncThreadContextValueToNodeQueue() override
virtual bool IsThreadContextAndShadowValuesDifferent() const override
virtual void UpdateThreadContextValueFromNodeShadow() override

Detailed Description

A class for the cross-thread manipulatable value. Can be used in situations where a value needs to be manipulated (read and/or written) from a thread context. The shadow value of the node is created in the thread context and can be manipulated there. An addition, a thread context value copy is created for direct manipulation in the thread context and to determine if the thread context value has been changed and the change should be synced back to the node context. All value synchronization between the threads is done without mutexes - only using lockfree commands queues.

Note: The template type of the class can be different from the node that will be synced - then value converting occurs on sync time.

CrossThreadValueNode constructor parameters:

  • node - The node to create the cross-thread manipulatable value for
  • threadContextRunQueue - The run queue for the thread context to post value-change commands to

    Note: When threadContextRunQueue is not set (nullptr), then the syncing will be unidirectional - i.e. value is not synced from node context to thread context. Value can then only be synced from thread context to node context (using AddSyncThreadContextValueToNodeQueue() method). This unidirectional syncing can be useful when the value is only written from the thread context and read in the node context (like updating values of read-only output signals, properties or arguments from thread).

  • onNodeRemove - Optional callback to be called when the node context reports node was removed

Note: The constructor of the CrossThreadValueNode should be always called from thread context and with the node context GetMemberAccessMutex() locked.

Member Function Documentation

CrossThreadValueNode::CrossThreadValueNode(ICDPNode *node, RunInThreadQueue *threadContextRunQueue, const std::function<void( CrossThreadValueNodeBase * pointerToMe ) > &onNodeRemove = {})

Copy constructor.

CrossThreadValueNode::~CrossThreadValueNode()

Destroys the instance of CrossThreadValueNode.

[override virtual] void CrossThreadValueNode::AddSyncThreadContextValueToNodeQueue()

Places a command to node context queue to sync the thread context to the node context value

Note: This method should be called only in the thread context.

T &CrossThreadValueNode::GetThreadContextValueRef()

Returns reference to thread context value for direct manipulation in thread context

Note: This method should be called only in the thread context

[override virtual] bool CrossThreadValueNode::IsThreadContextAndShadowValuesDifferent() const

[override virtual] void CrossThreadValueNode::UpdateThreadContextValueFromNodeShadow()

Copies the current shadow value to the thread context value

Note: This method should be called only in the thread context.

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

My account

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

© Copyright 2025 CDP Technologies. Privacy and cookie policy.

Return to top