You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pthread_cond_t facilitates wait()/notify() functionality, which aren't needed in the majority of cases. However, the monitor always allocates them, and this accounts for the large majority of the time spent when creating new Threaded objects.
Ways this could be avoided:
(ng only) Split wait/notify stuff into its own class, leaving ThreadedBase even more basic
Lazy-init pthread_cond_t (I haven't explored whether this is safe or not).
The text was updated successfully, but these errors were encountered:
Lazy initialization isn't an option since it's possible for multiple threads to try to use wait() simultaneously without using synchronized(). This would lead to a data race and memory leak.
If we decide to go with a separate class for this, ThreadedEvent would make sense, with a similar API to Python's threading.Event.
This would also simplify the majority use-case of wait() and notify() by avoiding the need for boilerplate synchronized blocks, amongst other things - the vast majority of uses of wait/notify involve some kind of boolean condition flag.
pthread_cond_t
facilitates wait()/notify() functionality, which aren't needed in the majority of cases. However, the monitor always allocates them, and this accounts for the large majority of the time spent when creating newThreaded
objects.Ways this could be avoided:
ThreadedBase
even more basicThe text was updated successfully, but these errors were encountered: