Set max size of the queue.

Using semaphore to set the max size of the task queue to avoid the size of task queue growing infinitely.
Once the size of queue reach the limit, the enqueue function will be blocked.