Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elegant and clear way to name a thread-safe function?

I'm looking for a naming convention for thread safe functions, meaning functions that can be called safely from multiple threads. But suppose I use :

void FooThreadSafe();

In your mind, do you think that :

This function will use locking mechanism and is safe to call concurrently ?

Or

This function can be called ONLY in a thread safe context ?

To me it's the first option, but many people think it's the second option. So I'm looking for a way to make it clear that you don't have to lock to call the function. Any idea ?

Thanks,

Noisetier

like image 354
noisetier Avatar asked Nov 08 '22 19:11

noisetier


1 Answers

Java uses Atomic or Concurrent as prefix.

For example AtomicReference<>, ConcurrentHashMap<>.

like image 79
Tet Avatar answered Jan 04 '23 03:01

Tet