shared - i need it to be useful
Neia Neutuladh
neia at ikeran.org
Sun Oct 21 16:32:54 UTC 2018
On Sat, 20 Oct 2018 22:47:14 -0700, Manu wrote:
> Looking at the meat of the program; you open a file, and distribute it
> to do accesses (I presume?)....
> Naturally, this is a really weird thing to do, because even if the API
> is threadsafe such that it doesn't crash and reads/writes are
> serialised, the sequencing of reads/writes will be random, so I don't
> believe any sane person (let alone an expert) would write this
> program... but moving on.
> Then you wait for them to finish, and close the file.
>
> Fine. You have a file with randomly interleaved data... for whatever
> reason.
I'd expect almost every nontrivial multithreaded program to do this. It's
called a log file.
You don't need to read data pointed at by a log file, but you do need to
read the FILE* or the file descriptor.
Database-like things using a journal file might need a shared file for
both reading and writing.
> So, you call closeFile immediately and read/write start returning null.
You start threads. You give them access to the log file. You wait for the
threads to exit. Then you close the file.
More information about the Digitalmars-d
mailing list