pgrx
pgrx copied to clipboard
How to initialize a `ConditionVariable` in a struct when shared memory is initialized.
I want to initialize a ConditionVariable
in a struct using ConditionVariableInit
function when shared memory is initialized.
Where should this be done?
Looking into pub fn shmem_init_locked<T: Default + PGXSharedMemory>(lock: &PgLwLock<T>) {
Only T:default()
is called.
If I understand everything correctly, a way to do this at shmem-init-time is currently not exposed. At "actual" (post-init) runtime, you just call ConditionVariableInit with a pointer.
Thank you @workingjubilee. I have called ConditionVariableInit
in the main function of the worker and it seems to be ok for my case.