implement write() queue max len threshold blocking