C++ command-line output pathname support
In the threaded PPL backend of ppl_lcdd, build_output_name shall accept a non-null null-terminated input pathname and an optional null-terminated output-directory pathname. It shall return the native input basename followed by .out, joined to the supplied nonempty directory or to . when that directory is null or empty. An empty basename shall yield .out. Native path separators and basename rules shall apply; in particular, a backslash in a POSIX basename shall be preserved. The inputs shall remain unchanged. The function shall not access the filesystem. Allocation and native pathname-conversion failures may propagate.
Preserving characters inside a native basename avoids conflating distinct basenames when routing threaded conversion output into a directory.
Internal function in demos/ppl_lcdd/ppl_lcdd.cc:
std::string build_output_name(const char* path_out, const char* name_in);
Compare native basename and join semantics for null, empty and explicit directories, trailing separators, empty and long basenames and literal backslashes. Through the actual command line, convert distinct POSIX input names that previously collided and compare both result files with a known conversion, in default and explicit output directories.
demos/ppl_lcdd/ppl_lcdd.cc; demos/ppl_lcdd/outputnamespec1.cc; demos/ppl_lcdd/check_named_output.sh.
Threadsafe_Queue shall serialize access to its FIFO. A successful try_pop shall assign and remove the oldest queued item; an empty queue shall return false without assigning an item. empty is a synchronized observation rather than a reservation. These operations require the element type's used copy/move operations to complete successfully when a completed queue action is required.
The pool shall select at least one worker. If starting a worker fails, the constructor shall stop and join every worker it has started before propagating the exception.
For a successfully constructed pool, submissions made before finalize or destruction shall be queued. Workers shall repeatedly claim and invoke queued work. finalize shall request stopping once the queue is drained; destruction shall request that stop and join every worker before returning. Work submitted before stopping shall be invoked once when work and queue operations complete normally. No submission may race with or follow the stop request. Work must not allow an exception to escape its worker entry point. The queue and pool shall not be copied, moved or assigned.
Queue locking, stop signalling and joining together determine whether a conversion task is executed and whether its storage remains alive.
Internal templates in the conversion tool:
template <typename T> class Threadsafe_Queue; template <typename Work> class Thread_Pool;
Queue operations: empty, push and try_pop. Pool operations: construction, submit, finalize and destruction. work_type names Work. The pool chooses its worker count from std::thread::hardware_concurrency, using one worker if that value is zero and capping the count by a positive task count when provided.
Inspect mutex ownership and FIFO removal, stop/drain ordering, and joins before queue destruction. Exercise multiple producers/consumers with uniquely numbered nonthrowing work and verify no lost or repeated invocation. Check the one-worker fallback and verify that a failure during partial construction stops and joins every started worker.
demos/ppl_lcdd/Thread_Pool_defs.hh; demos/ppl_lcdd/Thread_Pool_templates.hh; demos/ppl_lcdd/ppl_lcdd.cc.