DM_MUTEX_SCOPED_LOCK example

Can I request an example of using DM_MUTEX_SCOPED_LOCK? Thanks!

https://www.defold.com/ref/dmMutex/#DM_MUTEX_SCOPED_LOCK:mutex

For example:

DM_MUTEX_SCOPED_LOCK(subscribers_mutex) {
    subscribers.insert(std::make_pair(subscriber_id, subscriber));
}

or

{
    DM_MUTEX_SCOPED_LOCK(subscribers_mutex);
    subscribers.insert(std::make_pair(subscriber_id, subscriber));
}

The second example is more clear on your intentions and is how we use it.

2 Likes

You can check how I use it in DefVideoAds NE: defold-extension-unity-ads/defunityads/src/DefUnityCallback.cpp at b169c1ea31af4434bf16bafc53d2e8a7ccf7700a · AGulev/defold-extension-unity-ads · GitHub

3 Likes

Thank you both!

1 Like