Heikki Linnakangas wrote:
> Alvaro Herrera wrote:
>
>> Itagaki Takahiro wrote:
>>
>>
>>> Is it acceptable to use pthread in contrib module?
>>>
>> We don't have a precedent it seems. I think the requirement would be
>> that it should compile if pthread support is not present.
>>
>
> My thoughts as well. But I wonder, would it be harder or easier to use
> fork() instead?
>
>
I have just been down this road to some extent with parallel pg_restore,
which uses threads on Windows. That might be useful as a bit of a
template. Extending it to use pthreads would probably be fairly trivial.
The thread/fork specific stuff ended up being fairly isolated for
pg_restore. see src/bin/pg_dump/pg_backup_archiver.c:spawn_restore()
I think you should have it use pthreads if available, or Windows threads
there, or fork() elsewhere.
cheers
andrew