If scheduler observer is called too frequently, initializing a signal handler is going to be rather wasteful considering it only needs to be called once at initialization. Unless the observer has some hook that is only called once?
I know that using the observer will "work", and that is not what I was asking. The observer is going to be called as worker threads obtain work, so far as I can see, and that is extremely wasteful to put initialization code in that area that is frequently checked. Especially if the initialization code requires synchronization to ensure that this was a thread seen before to be initialized.
I appreciate your suggestion to look at the observer, but this is not what I want.
(2012-08-15 Added after #7) Sorry for not being more explicit earlier, but the calls happen very
infrequently indeed (probably only twice in a worker thread's lifetime,
perhaps more if an application thread explicitly uses different
The documentation states: "A task_scheduler_observer permits clients to observe when a thread starts or
stops participating in task scheduling." This is all the information provided.
Given this sentence, I inferred that the observer will be called during scheduling of tasks, in particular on the transition from an empty work-pool to a non-empty workpool. Perhaps this can be better worded?